Reputation: 9174
How can I override $(".className")
such that
if(className="xyz") then alert("Hello")
and then do what JQuery is doing.
Upvotes: 0
Views: 321
Reputation: 5349
Is this what you mean?
if ($('div[class="xyz"]').length) {
alert('Hello');
}
Upvotes: 0
Reputation: 45721
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.
Upvotes: 3
Reputation: 6602
try this :
if($('#selector').hasClass('classname')) alert('Hello')
Upvotes: 0