Mapping JSON properties to HTML ID to Easily Set Values - Javascript jQuery

Javascript examples for jQuery:Json

Description

Mapping JSON properties to HTML ID to Easily Set Values

Demo Code

ResultView the demo in separate window


<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
   </head> 
   <body> 
      <input id="name"> 
      <input id="addressOne"> 
      <script>
var address = {id: 100, name: "Gregg", addressOne: "111 1st Street"};
$('input').each(function(){
    $(this).val(address[this.id]);
});//from  w  w  w. j  a  va 2s . c o m

      </script>  
   </body>
</html>

Related Tutorials