JQuery Iterate through JSON - Javascript jQuery

Javascript examples for jQuery:Json

Description

JQuery Iterate through JSON

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from w w w  . ja  va2  s. c o m
$(document).ready(function(){
    var items = {"4":"AAA","2":"BBB"};
    $.each(items, function(k, values) {
        $('#d').append(k + ' = ' + values + "<br />");
        console.log(k);
        console.log(values);
    });
});
    });

      </script> 
 </head> 
 <body> 
  <div id="d"></div>  
 </body>
</html>

Related Tutorials