In Tritium,how to select li which have the same class as other?

73 views Asked by At
<ul class="parent">
   <li class="abc">1</li>
   <li class="abc">2</li>
</ul>

How to select li which have the same class as other?

2

There are 2 answers

0
maitry shah On BEST ANSWER

$('./ul[@class="parent"]/li[contains(text(),"1")]') This is a way you can select any li using text function

0
BGoers On

This will also work:

$('//ul[@class="parent"]/li[1]') #Targets the first "<li>".

$('//ul[@class="parent"]/li[2]') #Targets the second "<li>".