Mega Code Archive

 
Categories / JavaScript Tutorial / JQuery
 

Append value to table body

< html>   <head>     <script type='text/javascript' src='js/jquery-1.3.2.js'></script>     <script type='text/javascript'> $(document).ready(   function() {     $('input#tmpAddAlbum').click(       function($e) {         $e.preventDefault();               $('table tbody').append(           "<tr>\n" +           "  <td>\n" +            "    <input type='text' value='value' size='25' />\n" +            "  </td>\n" +           "  <td>1980</td>\n" +           "</tr>\n"         );       }     );   } );     </script>     <style type='text/css'> table {     width: 100%;     background: lightgreen; } th {     background: green;     color: lightgreen; }     </style>   </head>   <body>      <h4>C Albums</h4>      <table>        <thead>          <tr>            <th>Title</th>            <th>Year</th>                  </tr>        </thead>        <tbody>        </tbody>      </table>      <input type='submit' value='Add Album' id='tmpAddAlbum' />   </body> </html>