Sunday, June 3, 2012

Create HTML List using jQuery

Example to create HTML List using jQuery:

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8"/>
  <title>Mobile-Web-App: Create HTML List using jQuery</title>  
  <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
         
  <script > 
    $(document).ready(function(){ 
      var div_info = document.getElementById("info");
    
      var new_ul = $(document.createElement("ul"))

      $(create_li("Sunday")).appendTo(new_ul);
      $(create_li("Monday")).appendTo(new_ul);
      $(create_li("Tuesday")).appendTo(new_ul);
      $(create_li("Wednesday")).appendTo(new_ul);
      $(create_li("Thursday")).appendTo(new_ul);
      $(create_li("Friday")).appendTo(new_ul);
      $(create_li("Saturday")).appendTo(new_ul);
      $(new_ul).appendTo(div_info);
    }
  )          

  function create_li(item){  
    var new_li = $(document.createElement("li"));   
    $("<p>" + item + "</p>").appendTo(new_li);    
    return new_li;
  }      

  </script>
  
</head>
<body>
  <H1>Mobile-Web-App: Create HTML List using jQuery</H1> 
  <div id="info">
  </div>
  
</body>
</html>


Create HTML List using jQuery


Related:
- Create HTML List using Javascript


No comments:

Post a Comment