Home > Web Front-end > JS Tutorial > jQuery study notes: Creating DOM elements_jquery

jQuery study notes: Creating DOM elements_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:19:22
Original
1049 people have browsed it

Using DOM methods to create element nodes usually requires the use of document.createElement(), document.createTextNode(), and appendChild(), which is very troublesome.

And jQuery can directly create DOM elements using $

Copy code The code is as follows:

var oNewP = $("

Content created with jQuery

");

The above code is equivalent to javascript

Copy code The code is as follows:

            var oNewP2 = document.createElement("p");
                var oText = document.createTextNode("This is content created using the javascript method");
              oNewP2.appendChild(oText);

Example: Using jQuery to create DOM

Copy code The code is as follows:

Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template