开发者

jQuery find / is(':visible') problem

开发者 https://www.devze.com 2023-03-26 09:04 出处:网络
Please see the code here: http://jsfiddle.net/wQpTu/1/ For some reason, it always returns f开发者_运维百科alse on the .is(\':visible\') whether or not it is visible.

Please see the code here:

http://jsfiddle.net/wQpTu/1/

For some reason, it always returns f开发者_运维百科alse on the .is(':visible') whether or not it is visible.

Any reason why? Anything I should be doing differently?


You need to use:

var visibleElement = $('#holder').find("span#spanselect").is(":visible");

spanselect is an id, not a class.

$("#holder span#spanselect") would work just the same, by the way. For the record, you can changed is(":visible") to length ans saw it was equal to 0, and easily see the selector fails.

Example: http://jsfiddle.net/kobi/wQpTu/5/


You are using "." instead of "#". This will work:

var visibleElement = $('#holder').find("span.spanselect").is(":visible");
0

精彩评论

暂无评论...
验证码 换一张
取 消