jQuery USES each to process json data

  • 2020-06-01 08:14:29
  • OfStack

eg: when the corresponding value of ID is true in the incoming ID, add one class named focus to the corresponding ID tag, such as:

var obj = { id01:'true', id02:'flase', id03:'true'};

   if(val == 'true'){ 
      $('#' + key).addClass('focus'); 

Results: one class tag is added to the id01 and id03 ID labels.


The data of json are as follows:

{"Id": 10004, "PageName": "club"}, 
{"Id": 10040, "PageName": "qaz"}, 
{"Id": 10059, "PageName": "beauty"}

To manipulate this data with jquery, use $.each:

$.each(data, function(i, item) {

My own test is feasible.

That's all for this article, I hope you enjoy it.

Related articles: