What's the simplest way to tell if an attribute exists?
p = <abc name="foo" />;
js>p.@name.length()
1
js>p.@zebra.length()
0
I can use @attr.length()
but was wondering if there is an isAttributePresent()
or som开发者_StackOverflow中文版ething.
NOTE: This is not in a browser, this is just a javascript interpreter based on core Mozilla Javascript 1.8 with E4X enabled.
You can use
'@name' in p
This will return true
or false
depending on existence of said attribute.
精彩评论