So I need to find an element in an iframe that is the exact same element of that that is in the webpage (the iframe is of the same page). I need to figure out what the index is of the elements without id’s with jquery so I can get the same element in an iframe.
Edit: How can I find the index of an element?
i.e. for this html:
<div>
<a>1</a>
<a>2</a>
<a>3</a>
<a id="someA">4</a>
<a>5</a>
<a>6</a>
<a>7</a>
</div>
How would I find the index (so I can it by doing $('a')[index]) of one of the random anchor elements from it’s jQuery object?
(By doing $('#someA').siblings()[Math.floor(Math.random()*6)].getIndex())
jsfiddle: http://jsfiddle.net/YP5hQ/2/
Alright this is it: http://jsfiddle.net/dan_barzilay/ZB2vE/
But you got the function all wrong.. i suggest that you will learn about:
.get()and.index()*notice that i havn’t used any native javascript. it’s no need when you have the wonderfull jQuery 🙂
**I changed this line:
$(elem).html(c);to this:$(elem).html(h);because i thought you ment to do it withhif not simply change thehwith ancGood Luck!