javascript - how to iterate a result of jquery selector -
i want iterate result of query selector.
html code
<nav id="navigation"> <a href="#" tabindex="1" class="active_nav">nav1</a> <a href="#" tabindex="2">nav2</a> <a href="#"tabindex="3">nav3</a> </nav> when use javascript
alert($("#navigation >a")[0]); the result tag a href attribute don't know why.
use $.each
$("#navigation > a").each(function() { console.log(this.href) }); $('#navigation > a')[0] ^ ^---- selects 1st dom object jquery object | nothing index of element among | list of elements |------- gives children of nav(3 anchor tags in case) jquery object contains list of matched elements
Comments
Post a Comment