Thursday 27 September 2018

Iterating a JavaScript object's properties using jQuery



Is there a jQuery way to perform iteration over an object's members, such as in:



    for (var member in obj) {
...
}



I just don't like this for sticking out from amongst my lovely jQuery notation!


Answer



$.each( { name: "John", lang: "JS" }, function(i, n){
alert( "Name: " + i + ", Value: " + n );
});


each



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...