当我点击一个链接时,我将它的 href 值放在一个变量中(数字代表一个唯一的 id),然后......我有一个单独的 ul:
<ul class="class_one">
<li class="class_two"><a href="2345">some text</a></li>
<li class="class_three"><a href="6789">some text</a></li>
</ul>
我想要做的是看看我的“ul”中是否有任何“a”,它具有与我存放在变量中的相同的 id。
我尝试了这样的事情(当然没有结果):
$('ul.class_one').find('a[href="' + myVar + '"]')
//and if it finds no element do something
//i think is something wrong with the quotes ('a[href="' + myVar + '"]')