Home  >  Article  >  Web Front-end  >  JQuery each method of printing JS objects_jquery

JQuery each method of printing JS objects_jquery

WBOY
WBOYOriginal
2016-05-16 17:15:35900browse

We know that JavaScript can use alert to output the value of a variable, but sometimes it returns an object, data in json format. jQuery can use this method to loop through and read out the value of the object. If the object name is obj, it will loop through and print it. Value:

Copy code The code is as follows:

$.each(obj,function(key, val){
if($.isPlainObject(val) || $.isArray(val)){
subObj(val);
}else{
alert(key '=' val);
}
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn