You can use nth-of-type
with JQuery to find an item by index, something similar to:
<script>
var foundEl = $( "#ucprodres-in-stock > div:nth-of-type(2)" );
</script>
Here is the link to the documentation:
http://api.jquery.com/nth-of-type-selector/
For example:
<form>
<fieldset>
<section id="demo">
<!-- some code-->
</section>
<section id="test">
<!-- some code-->
</section>
<section id="hello">
<!-- some code-->
</section>
</fieldset>
</form>
This will print "test" in the console:
var el =$("form>fieldset>section:nth-child(2)");
console.log(el.attr("id"));
Update 1:
Based on your resent update here is how I would do it, I would search for the parent siblings with the class .qty-avail
, something like:
$("input").on('change',function(){
var t = $(this).parent().siblings(".qty-avail").text().trim();
alert(t);
});
http://jsfiddle.net/X5Q4H/1 or as it is in your code sample: