Reputation: 189796
What's the simplest way to tell if an attribute exists?
p = <abc name="foo" />;
js>[email protected]()
1
js>[email protected]()
0
I can use @attr.length()
but was wondering if there is an isAttributePresent()
or something.
NOTE: This is not in a browser, this is just a javascript interpreter based on core Mozilla Javascript 1.8 with E4X enabled.
Upvotes: 2
Views: 706
Reputation: 196187
You can use
'@name' in p
This will return true
or false
depending on existence of said attribute.
Upvotes: 4