Create node, insert node for jquery_dom node operation

Source: Internet
Author: User

First, create a node
In order to make the page more intelligent, sometimes we want to dynamically add an element tag on the HTML structure page, then the first thing to do before inserting is: Create the node

<Scripttype= "Text/javascript"src= "Jquery-1.12.3.min.js"></Script><Script>$(function(){     varBox= $('<div id= "box" > Nodes </div>'); //Create a node     $('Body'). append (box); //inserting a node inside a <body> element});</Script></Head><Body>    </Body>

Second, insert the node
In the process of creating a node, we have actually demonstrated how to insert a node by using the. Append () method. But apart from this method, JQuery provides several other ways to insert nodes.

  

<Scripttype= "Text/javascript"src= "Jquery-1.12.3.min.js"></Script><Script>$(function(){     varBox= $('<div id= "box" > Add node </div>'); //Create a node     $('Div'). append (box); //Insert a node behind a div inside a <body> element});</Script></Head><Body>    <Div>Node</Div>    <Div>Node</Div></Body>
<Scripttype= "Text/javascript"src= "Jquery-1.12.3.min.js"></Script><Script>$(function(){     $('Div'). Append (function(index, HTML) {//inserting nodes using anonymous functions, HTML is the original node        return '<div> Nodes </div>'; });});</Script></Head><Body>    <Div>Node</Div>    <Div>Node</Div></Body>

Create node, insert node for jquery_dom node operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.