Javascript examples for jQuery Method and Property:append
Assigning IDs to several child elements
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> <script type="text/javascript"> $(window).load(function(){//www .j av a 2s . com $("#wrapper").append( $("<div>").attr("id", "main-div") .append($("<button>") .text("X") .attr("id", "myButton"))) }); </script> </head> <body> <div id="wrapper"></div> </body> </html>