In the web page, I have some codes like
<span commandArgument="a">A</span>
<span commandArgument="b">B</span>
I want to use javascript to get the commandArgument values of the spans, and the code I wrote is
var spans = document.getElementsByTagName("span");
var value = spans[0].commandArgument;
It works in IE but fails in Firefox.
IE gets value = "a" and Firefox gets value = undefined.
Is there any method to get the values that works in both browser? Thanks!!
Have you tried .getAttribute("commandArgument")
?
...and its ugly cousin must be mentioned, .setAttribute("commandArgument", "c")