鉴于html:
<div id="t">
<a class="xx">xx</a>
<a class="yy">yy</a>
<a class="zz">zz</a>
</div>
现在,如果我想获取类为xx
or的链接zz
,也就是说我想得到这个:
<a class="xx">xx</a>
<a class="zz">zz</a>
我试过这个:
$("#t a").each(function(){
if($(this).is(".xx,.yy"){
//here how to get the out the HTML of the current a element?
}
});
有什么选择吗?
我注意到有两个答案,但似乎他们误解了我。
$("#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`.
}
});