How i can read index from element? example:
I have code:
<div class="a"> <span id="el">Yeah!</span> <span class="span">1</span> <span class="span">2MANO</span> </div> and javascript: var mySpan = document.getElementsByTagName("span")[0]; // it span id="el" its ok,
but how i can read from this span index of this element
var span= document.getElementById("el"); // i should get index 0 but i cant do that
spans in the document? Something else entirely?var mySpans = [].slice.call(document.getElementsByTagName("span")); var index = mySpans.indexOf(document.getElementById("el"))