开发者

jQuery selector for all nodes in a given namespace

开发者 https://www.devze.com 2023-03-17 14:22 出处:网络
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:

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 wild开发者_JAVA百科card is not accepted.

TIA for your lights.


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

精彩评论

暂无评论...
验证码 换一张
取 消