【问题标题】:In Tritium,how to select li which have the same class as other?在氚中,如何选择与其他具有相同类的li?
【发布时间】:2014-12-01 09:04:55
【问题描述】:
<ul class="parent">
   <li class="abc">1</li>
   <li class="abc">2</li>
</ul>

如何选择与其他类相同的li?

【问题讨论】:

    标签: moovweb tritium


    【解决方案1】:

    $('./ul[@class="parent"]/li[contains(text(),"1")]') 这是一种可以使用文本函数选择任何 li 的方法

    【讨论】:

      【解决方案2】:

      这也可以:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-08
        • 1970-01-01
        • 2012-09-18
        • 1970-01-01
        • 1970-01-01
        • 2022-12-18
        相关资源
        最近更新 更多