【问题标题】:JQuery selector namespaceJQuery 选择器命名空间
【发布时间】:2016-07-16 03:20:40
【问题描述】:

我正在尝试定位此节点:

<ns1:image href="http://broadcast.lds.org/XML/LDSRadio/LDSRadio_EnduringItWell.jpg" />

从这里 (http://feeds.lds.org/EnduringItWell)

如果我这样做,它会起作用:

$(result).find('ns1\\:image').length

如何编写选择器以便在没有“ns1”的情况下选择它? (因为这个 'ns1' 可能不同)

我试过了,但它不起作用:

 $(result).find('\\:image').length

【问题讨论】:

    标签: jquery namespaces selector


    【解决方案1】:

    您不能使用直接选择器来选择它,而是可以这样做,

    $(result).find("*").filter(function(){
      return this.tagName.toLowerCase().indexOf(":image") > -1;
    });
    

    DEMO

    【讨论】:

      猜你喜欢
      • 2011-01-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-04
      • 2015-12-21
      • 2012-07-15
      • 2010-11-16
      • 1970-01-01
      相关资源
      最近更新 更多