jQuery each object, element

スポンサーリンク
var $collection = $("ul > li");

$collection.each(function(index, element){

console.log("index is "+index);

console.log("Javascript element is"+element.innerHTML);

console.log("jQuery element is "+$(element).text());

});

var objectCollection = {

school : {

city: "Vancouver",

province: "BC"

}

};

$.each(collection, function(key, value)){

console.log("key is "+key);

console.log("value is "+value);

$.each(value, function(nestedKey, nestedValue){

console.log("Nested key is "+nestedKey);

console.log("Nested value is "+nestedValue);

});

}

コメント

タイトルとURLをコピーしました