jQuery selector for all nodes in a given namespace

谁说胖子不能爱 提交于 2019-12-20 02:56:10

问题


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\\:*")

But the wildcard is not accepted.

TIA for your lights.


回答1:


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;
});


来源:https://stackoverflow.com/questions/6580999/jquery-selector-for-all-nodes-in-a-given-namespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!