Given the htmls:
<div id="t">
<a class="xx">xx</a>
<a class="yy">yy</a>
<a class="zz">zz</a>
</div>
Now how about if I want to get the links whose class is xx
or zz
, that's to say I want to get this:
<a class="xx">xx</a>
<a class="zz">zz</a>
I tried this:
$("#t a").each(function(){
if($(this).is(".xx,.yy"){
//here how to get the out the HTML of the current a element?
}
});
Any alternatives?
I noted that there are two answers, but it seems that they misunderstand me.
$("#t a").each(function(){
if($(this).is(".xx,.yy"){
//here I want to get the full HTML of the `a` element
// That's to say, I want to get `<a class="xx">xx</a>`
// I can not use $(this).html() or $(this).text() which will only return the `xx`.
}
});