javascript за всеки
const avengers = ['thor', 'captain america', 'hulk'];
avengers.forEach((item, index)=>{
console.log(index, item)
})
jquery всеки
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
jquery всеки
//Array
$.each( arr, function( index, value ){
sum += value;
});
//Object
$.each( obj, function( key, value ) {
sum += value;
});
цикъл на jquery през елементи
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
цикъл на jquery чрез масив
var arr = ['one','two','three','four','five'];
$.each(arr, function(index, value){
console.log('The value at arr[' + index + '] is: ' + value);
});
jquery за всеки
$.each( obj, function( key, value ) {
alert( key + ": " + value );
});