Why won't this DOM element disappear?
I have a page that uses jQuery with a small glitch.
I managed to get this down to a simple example that demonstrates the problem:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function hideIt()
{
$('#hideme').fadeOut('slow', function() { $(this).remove(); } );
}
</script>
</head>
<body>
<div id='#hideme'>Hide me!</div>
<button onclick='hideIt();'>Hide</button>
</body>
</html>
As you would expect, the problem is simple: the caption doesn't disappear.
What simple thing开发者_如何学Go did I overlook? (Or if it's not a simple thing, what complicated thing did I miss?)
Try removing the #
in <div id='#hideme'>Hide me!</div>
:)
The selector is not finding your div, because you have an #
character on it:
Change:
<div id='#hideme'>Hide me!</div>
To:
<div id='hideme'>Hide me!</div>
The ID of the div should be "hideme
" not "#hideme
"
精彩评论