开发者

Checking whether a class name exists?

I want to check whether a class name exist irrespective of its id or tag.

Suppose I'm having class name "temp".

I need to check something like jQuery(开发者_Go百科'.temp').length -> this is not working


jQuery.fn.exists = function(){
    return jQuery(this).length>0;
}

if ($(selector).exists()) {
    // Do something 
}


$('.temp').length does work.

See http://jsfiddle.net/ThiefMaster/wEXVu/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜