Reputation: 1577
I would like to execute a callback after a particular div gets removed. I tried this, but it does not work:
$('div.myclass').remove(function(){
alert ("div removed");
});
Anyone know how to execute such a callback? I checked the jQuery documentation for remove(), but it does not mention anything about callbacks. Does this mean remove() does not support a callback?
UPDATE: Here is a more detailed explanation of what I am trying to accomplish. I have a div with class 'nojavascript'. I want to display this div only if the user does not have javascript enabled. Here is the code:
$(document).ready(function() {
$('div.nojavascript').remove();
... // additional jquery commands
});
The problem: this div is sometimes displayed to the user for a brief moment, even though javascript is enabled. It's as though the page is displayed to the user before .remove() finishes executing. I am trying to ensure that the user never sees this div, even for a brief moment, if javascript is enabled.
Upvotes: 0
Views: 1328
Reputation: 1959
It seems like you might be have better luck using <noscript>
. This type of thing is exactly what the tag is designed for.
<html>
<head>...</head>
<body>
...
<noscript>
<div class="noscript">This doesn't display to users who have JavaScript enabled</div>
</noscript>
<div>
<p> This displays to JavaScript and non-Javascript alike!</p>
</div>
...
</body>
</html>
Any particular reason you can't/don't want to use <noscript>
?
Upvotes: 1
Reputation: 94101
Does this mean remove() does not support a callback?
Yup it means exactly that I'm afraid.
And then.... jQuery remove() callback?
Upvotes: 0