A good way for jquery to create a new Node object (custom structure/content)

Source: Internet
Author: User

Html
CopyCode The Code is as follows: <! Doctype HTML>
<HTML>
<Head>
<SCRIPT class = "jsbin" src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </SCRIPT>
<Meta charset = UTF-8/>
<Title> jsbin-Online JS/CSS debugging tool </title>
<! -- [If IE]>
<SCRIPT src = "http://html5shiv.googlecode.com/svn/trunk/html5.js"> </SCRIPT>
<! [Endif] -->
<Style>
Article, aside, figure, footer, header, hgroup,
Menu, NAV, section {display: block ;}
</Style>
</Head>
<Body>
<P id = "hello"> Hello ostools </P>
</Body>
</Html>

Javascript Copy codeThe Code is as follows: // JQ creates a new Node object;
// Example: <Div id = 'mydiv 'class = 'menu'> </div>
VaR objnewdiv = $ ('<div>', {'id': 'mydiv ', 'class': 'menu '});
Objnewdiv.html (123456 );
$ ('# Hello'). append (objnewdiv );
Console. Log (objnewdiv );

Result:

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.