问题
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