I don’t know why my code doesn’t work.
$("#example").find('LI A').hasClass("sth").each(function(){alert($(this))});
Firebug says:
$(“#example”).find(‘LI A’).hasClass(“sth”).each is not a function
The problem in this code is each, because if I delete it, it giving me no errors.
I need to pass founded value of “a” element to array.
hasClassfunction returns boolean not a jQuery object. thus it doesn’t have theeachfunction.You probably meant this:
Or this (which is better):
Read the docs: