【问题标题】:JQuery. Accessing Elements in the DOM below and object查询。访问下面 DOM 中的元素和对象
【发布时间】:2011-04-18 12:42:01
【问题描述】:

我正在使用一个返回 JQuery 对象的 API,该对象是对 DIV 容器的引用。我知道我在 DIV 容器内的结构。我基本上需要从第一个读取一些属性。 我尝试将标准选择器从我的对象中链接出来,但出现错误。

XML 过滤器应用于非 XML 值 ({selector:"div.panes > div.slice(0,1)", context:({}), 0:({}), length:1}) [打破这个错误] var svideo = $(api.getCurrentPane()).('a').get(0);

【问题讨论】:

    标签: jquery-selectors


    【解决方案1】:

    更改代码以使用.find() 来获取后代元素,例如直接引用 DOM 元素:

    $(api.getCurrentPane()).find('a').get(0)
    //or..
    $(api.getCurrentPane()).find('a')[0]
    

    或者如果你想要一个 jQuery 对象...

    $(api.getCurrentPane()).find('a:first')
    //or..
    $(api.getCurrentPane()).find('a:eq(0)')
    //or..
    $(api.getCurrentPane()).find('a').eq(0)
    

    【讨论】:

      猜你喜欢
      • 2012-05-01
      • 1970-01-01
      • 2011-10-21
      • 2013-06-22
      • 2015-05-08
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      • 2014-03-18
      相关资源
      最近更新 更多