I want to know if a div exists within the DOM or not. I have a notification on the site, at the very top of the page, where the user can click on it, and it will slideUp. I have another jquery event that will depends on knowing whether this div still exists in the DOM. I want a simple script that will produce a Boolean value of whether of not this Div exists or not. I tried
if($('#cookies_notification').css('display','block'))
which seems to acknowledge if the div is there, but I need to also know if it is NOT there, I tried using 'else' but no luck.
So what's the best way to check if an element exists in the DOM or not?
UPDATE Ok, I was mistaken, I don't think it leaves the DOM on slideUp, so I need to know if sliedUp on the element has occured.
UPDATE 2
I guess I could add $('#cookies_notification').css('display','none')
to the click event when the notification scrolls up, then it will detect it. That's the only solution I can conceive.
UPDATE 3 Oh, adding the css code in removes the slideup effect.
$("#cookies_notification").click(function(){
$(this).slideUp().css('display','none');
});
How can I make it slideup and then change the display?