Reputation: 267049
I have an element like this:
<div id="foo_<?php echo $id;?>" class="hidden"></div>
I'm trying
if ($("#foo_ " + id).is(':hidden'))
{
//stuff
$("#foo_ " + id).html(html).slideDown('fast');
}
I've checked repeatedly, the div foo_233
is being found in firebug and is being shown as hidden. The id is passed on to the javascript function correctly. But still the above lines aren't working. What could be wrong? Its very frustrating..
Upvotes: 1
Views: 674
Reputation: 342635
The space in your selector:
if ($("#foo_ " + id).is(':hidden'))
{
//stuff
$("#foo_ " + id).html(html).slideDown('fast');
}
Get rid of it:
if ($("#foo_" + id).is(':hidden'))
{
//stuff
$("#foo_" + id).html(html).slideDown('fast');
}
Presumably, your div IDs should look like "foo_5"
but the selector your were building was "foo_ 5"
, which is why your if condition never evaluates to true.
Upvotes: 6