Skip to content

Instantly share code, notes, and snippets.

@carlosrojaso
Created May 15, 2014 10:46
Show Gist options
  • Save carlosrojaso/25cbe18abee97801a434 to your computer and use it in GitHub Desktop.
Save carlosrojaso/25cbe18abee97801a434 to your computer and use it in GitHub Desktop.
Jquery each
// Returns "lots of extra whitespace"
$.trim( " lots of extra whitespace " );
var myArray = [ 1, 2, 3, 5 ];
if ( $.inArray( 4, myArray ) !== -1 ) {
console.log( "found it!" );
}
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
$( "li" ).each( function( index, element ){
console.log( $( this ).text() );
});
// Logs the following:
// Link 1
// Link 2
// Link 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment