开发者

jQuery selector for all nodes in a given namespace

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜