Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
<ul class="parent"> <li class="abc">1</li> <li class="abc">2</li> </ul>
如何选择与其他具有相同类的li?
$('./ul[@class="parent"]/li[contains(text(),"1")]') 这是一种可以使用文本函数选择任何 li 的方法
这也将起作用:
$('//ul[@class="parent"]/li[1]') #Targets the first "<li>". $('//ul[@class="parent"]/li[2]') #Targets the second "<li>".