how can i get the last div with class a in a div the id = test ? in this case i have to get the div with content = 1000
<div id="test">
<div class="a">1</div>
..
..
<div class="a>1000</div>
</div>
how can i get the last div with class a in a div the id = test ? in this case i have to get the div with content = 1000
<div id="test">
<div class="a">1</div>
..
..
<div class="a>1000</div>
</div>
Without jQuery:
var divs = document.getElementById("test").getElementsByTagName("div");
var lastChild = divs[divs.length - 1];