Saturday, November 1, 2014

jQuery $.each(array, callback) and $.each(object, callback)

$.each(array, callback)
 
$.each([10,20],function(index,value){
    alert(index+" "+value);
});


Note: index and value can be any name

$.each(object, callback);

var object = {
    "color":"red",
    "font-size":"10px"
};

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


Note: key and value can be any name.

No comments:

Post a Comment