musings

March 13, 2008

Iterate through jQuery objects with each()

Filed under: jQuery — aliaspooryorik @ 10:22 am

I always forget how to do break out of the each() method when iterating through a jQuery object.

<script type="text/javascript">
/* <![CDATA[ */
$('#rates-frm').submit(function(){
	var bValid = true;
	$('#rates-frm input[@type="text"]‘).each(function(i, o){
		alert(’index: ‘ + i + ‘ object id: ‘ + o.id);
		if (i > 5) {
			return false;
		}
	});
});
/* ]]> */
</script>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.