开发者

Extending jQuery's className selector

How can I override $(".className") such that

if(className="xyz") then开发者_Go百科 alert("Hello")

and then do what JQuery is doing.


From what I understand, you want to override/extend the method in jQuery that finds nodes. I can't find any hooks and/or listeners that can be attached to that functionality in the code, so I guess you'll have to modify the source code if you want to achieve this functionality.

I'd suggest adding some sort of event listener interface so you can attach this to arbitrary selectors that fit your needs.


try this :

if($('#selector').hasClass('classname')) alert('Hello')


Is this what you mean?

if ($('div[class="xyz"]').length) {
  alert('Hello');
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜