I'm a noob with jQuery and was wondering why this needed the "jQuery(function() {});" for my .each() to work.
Given a simple table with 5 rows ( tags), I wanted to loop through all the tags and just print out the index. So in this example, I would expect to see 1,2,3,4,5 in my console log. It seems like it has something to do with the .each() method?
One thing to note is that I'm able to add a clicking event $(#someId).live('click', function()... That seems to work fine outside of the jQuery(function(){}); block...so I'm a little confused as to why the .each() didn't work.
Thanks.
<script type="text/javascript">
jQuery(function() {
$("#table_id > tr").each(function(index) {
console.log(index);
});
});
</script>