JQuery Object Creation

From CoderLearner
Jump to: navigation, search

Description

Create object in jQuery.

Syntax

 var users= {name:"Bob",age:39};
  • Access object
  users.name
  user.age

Example

<html>
    <head>
        <title>Object</title>
         <script type="text/javascript" src="jquery-1.8.3.js"></script>
            <script type="text/javascript">
            $().ready(function(){
                var users= {name:"Bob",age:39};
               $('#show_text').html(users.name + " is " + users.age + " year old ");
            });
        </script>
        
    </head>
    <body>
     
        <div id="show_text"></div>
    </body>
</html>

Result

Bob is 39 year old