Sunday, May 13, 2012

jQuery .appendTo() - add something on HTML at run-time

Example to add something to HTML at run-time using jQuery .appendTo()

<!doctype html>
<head>
 <title>Mobile-Web-App: jQuery, .attr()</title>
 <meta charset="utf-8">
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
 <script type="text/javascript">

  $(document).ready(function(){
  
   $("<p>Add what you want to HTML</p>")
    .appendTo("#addhere");

  });
 </script> 
 
</head>
<body>
<p><b>Mobile-Web-App: jQuery, add to HTML</b></P>
<div id="addhere"></div>
</body>
</html>


jQuery .appendTo()


Related:
- Add HTML elements using Javascript code


No comments:

Post a Comment