jquery eah code example

Example 1: jquery foreach

$.each( obj, function( key, value ) {
  alert( key + ": " + value );
});

Example 2: jquery each array object

$.each(largeJSONobject.ReleatedDoc, function (index,value) {
    $('select.mrdDisplayBox').addOption(value.Id, value.Id + ' - ' + value.Number, false);
});

Example 3: jquery eah

<ul>
  <li>foo</li>
  <li>bar</li>
</ul>

$( "li" ).each(function( index ) {
  console.log( index + ": " + $( this ).text() );
});

//be aware that the .each() method is unnecessary here:
$( "li" ).each(function() {
  $( this ).addClass( "foo" );
});
 
//instead, you should rely on implicit iteration:
$( "li" ).addClass( "bar" );