【问题标题】:Is there a way to access an elements parent in tritium?有没有办法访问氚中的元素父级?
【发布时间】:2015-11-24 15:26:25
【问题描述】:

例如,假设有这个 html:

<div>
  <div id="divchild"></div>
</div>

是否有办法从子元素命名空间访问父 div,例如:

$$('#divchild'){
  # Access parent div here
  $$('< div'){
    # somethere here
  }
}

有没有办法采取非工作示例并使其工作?谢谢。

【问题讨论】:

    标签: css-selectors moovweb tritium


    【解决方案1】:

    不使用 css 选择器。您需要使用 xpath 选择器:

    $(".//div[div[@id='divchild']]") {
        # something here
    }
    

    $(".//div[@id='divchild']/parent::div") {
        # something here
    }
    

    将选择父 div。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-23
      • 2018-11-08
      • 2022-08-12
      • 2020-09-15
      • 1970-01-01
      • 1970-01-01
      • 2011-07-14
      • 1970-01-01
      相关资源
      最近更新 更多