The examples in this article describe the common ways in which jquery dynamically creates HTML elements that are useful when using jquery for Web programming. Share to everyone for your reference. The specific methods are as follows:
In general, you can create HTML elements dynamically in the following ways:
1, use jquery to create the syntax of the elements
2, the dynamic content into the array, and then traverse the array dynamic creation of HTML elements
3, the use of template
1. Append to the jquery object using the jquery dynamic creation element.
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<script src=" Scripts/jquery-1.10.2.js "></" script>
<script type= "Text/javascript" >
$ (function () {
$ (' <input/> ', {
ID: ' CBX ',
name: ' CBX ',
type: ' checkbox ',
checked: ' Checked ',
click:function () {
alert ("Dot Me ~ ~");
}
}). Appendto ($ (' #wrap ')
); </script>
The effect is as shown in the following illustration:
2. First put the content into the array, and then iterate through the array of HTML
The effect is as shown in the following illustration:
I believe that this article on the use of jquery for the web design has some reference value.