[jQuery] :visible change
[jQuery] :visible change
I'm stumped on a 1.3.2 change. Here is the scenario:
// Node tree:
// - div.groupItem
// - div.itemHeader
// - a.closeEl
// - div.itemContent
// - All the enclosed html
//
// When the closeEl node is clicked, act on its parent .groupItem's
// corresponding .itemContent.
Then the jQuery (presuming ele is the element passed to a 'click'
handler:
var targetContent = $(ele).parent().siblings('div.itemContent');
if (parseInt(targetContent.css('height')) > 1) {
targetContent.slideUp(300);
$(ele).html('[+]');
} else {
targetContent.slideDown(300);
$(ele).html('[-]');
}
return false;
This works. However, the more obvious and intentional version directly
below doesn't work and I can't tell why.
var targetContent = $(ele).parent().siblings('div.itemContent');
if (targetContent.is(':visible') {
targetContent.slideUp(300);
$(ele).html('[+]');
} else {
targetContent.slideDown(300);
$(ele).html('[-]');
}
return false;
The .is(':visible') always returns true. Am I mistaking how to use
this? Is there a much keener way to handle it that I'm not seeing?
Thanks,
Steve