Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
113
rated 0 times [  119] [ 6]  / answers: 1 / hits: 16942  / 11 Years ago, thu, july 4, 2013, 12:00:00

I'm trying to remove an entire div on page load. Currently I'm trying to use:



$(document).ready(function(){    
$(#removeme).remove();
});


with the HTML



<div id=removeme>If JS enabled remove this!</div>


I've been searching for hours, using many variations including getElementById. No luck.



Javascript/jQuery aren't languages I use often.



All help is appreciated. Thanks!



Edit: Fixed, page I was adding it to was having some issues (another dev built it). I put the code into an existing JS file instead and it works. Thank you all.


More From » jquery

 Answers
9

The code you are showing in your question works, as proven by @barmar :



http://jsfiddle.net/barmar/epsZe/


If it doesn't work for you, it is most likely because you have an error in your Javascript before you reach the code displayed here. Also, ensure that you have included Jquery before-hand.



To find where previous errors could have happened, you can look inside your Javascript console. Here is a question where it is described where to find your console on most browsers :



What is console.log and how do I use it?



If you don't want to use the console, you can put alerts in your Javascript code until you find where they stop displaying.


[#77194] Wednesday, July 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kieraelsies

Total Points: 718
Total Questions: 103
Total Answers: 104

Location: England
Member since Sun, May 21, 2023
1 Year ago
kieraelsies questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Tue, Feb 23, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Mon, Sep 16, 19, 00:00, 5 Years ago
;