jquery templet

jquery templet
 In this article, we are going to see, jquery templet basic example

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script> 
<table border="1">
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody id="userslist"></tbody>
  <script id="template" type="text/x-jquery-tmpl">
      <tr>
          <td>${name}</td>
          <td>${age}</td>
      </tr>
</script>
</table>

var users=[
    {name: 'dev1', age: 24},
    {name: 'dev2', age: 28},
    {name: 'dev3', age: 22}
];
$("#template").tmpl(users).appendTo("#userslist");

Post a Comment

0 Comments