给定名称空间中所有节点的jQuery选择器 [英] jQuery selector for all nodes in a given namespace

查看:87
本文介绍了给定名称空间中所有节点的jQuery选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以轻松地在命名空间中选择具有给定名称的所有节点:

I can easily select all nodes with a given name in a namespace:

$("namespace\\:nodename")

但是我需要更多:我想选择给定名称空间中的所有节点.理想情况是:

But I need more: I want to select all nodes in a given namespace. Ideally, this:

$("namespace\\:*")

但是不接受通配符.

灯光的TIA.

推荐答案

由于所有选择器不支持名称空间,您可以单独使用它(以匹配所有元素),然后应用 filter ()自己检查名称空间:

Since the all selector is not supported with a namespace, you can use it on its own (to match all the elements), then apply filter() to check the namespace yourself:

$("*").filter(function() {
    return this.nodeName.toLowerCase().indexOf("namespace:") == 0;
});

这篇关于给定名称空间中所有节点的jQuery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆