Home  >  Article  >  Web Front-end  >  jQuery creates DOM element instance parsing_jquery

jQuery creates DOM element instance parsing_jquery

WBOY
WBOYOriginal
2016-05-16 16:19:291072browse

The examples in this article describe the techniques for using jQuery to create DOM elements. Share it with everyone for your reference. The specific analysis is as follows:

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 using 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 javascript method");
oNewP2.appendChild(oText);

Example: Use jQuery to create DOM
Copy code The code is as follows:

Using jQuery greatly shortens the code length. Saves writing time.

I hope this article will be helpful to everyone’s jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn