Operations on dom nodes by js and jquery (Create/append)

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script src = "jquery-1.9.1.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ('# Button1'). click (function (){
// Var ha = '<p> a </p> ';
// $ ('Div '). append (ha );
// 1
// Var w = '<a href = "#"> f4 </a>'
// $ ('Div '). append (w );
// Var sele = '<select> <option> 1 </option> <option> 2 </option> <option> 3 </option> </select>'
// $ ('Div '). append (sele );
})
})
// 2var pstr = '<p> <B> <I> the Yellow River enters the ocean </br> to reach the next level </br>/ i> </B> </p> '; $ ('div '). append (pstr); change it to js for writing, the effect is the same
Function ha (){
// Var p = document. createElement ('P ');
// Var B = document. createElement ('B ');
// Var I = document. createElement ('I ');
// Var neirong1 = document. createTextNode ('day by day ');
// Var br1 = document. createElement ('br ')
// Var neirong2 = document. createTextNode ('Yellow River currents ');
// Var br2 = document. createElement ('br ')
// Var neirong3 = document. createTextNode ('thousands of miles away ');
// Var br3 = document. createElement ('br ')
// Var neirong4 = document. createTextNode ('upgrade ');
// I. appendChild (neirong1 );
// I. appendChild (br1 );
// I. appendChild (neirong2 );
// I. appendChild (br2 );
// I. appendChild (neirong3 );
// I. appendChild (br3 );
// I. appendChild (neirong4 );
//
// B. appendChild (I );
// P. appendChild (B );
// Document. getElementById ('did1'). appendChild (p );
}
</Script>
</Head>
<Body>
<Input id = "Button1" type = "button" value = "create node"/>
<Input id = "Button2" type = "button" value = "2" onclick = "ha ()"/>
<Div id = "div1"> </div>

Related Article

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.