<strong>HTML <br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="10979" class="copybut" id="copybut10979" onclick="doCopy('code10979')"><u>複製代碼</u></a></span> 代碼如下:</div> <div class="codebody" id="code10979"> <br><br> 代碼如下:<br><br> <br> <br><doc0pe html> <br> <br> <br><script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> <br><meta charset="utf-8"> <br><title>JsBin-線上js/css調試工具</title> <br><!--[if IE]> <BR>< script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <BR><![endif]--> <br><style> <BR>article, aside , figure, footer, header, hgroup, <BR>menu, nav, section { display: block; } <BR></style> <br> </doc0pe> </div> <br><p id="hello">Hello OSTools</p> <strong> </strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="2693" class="copybut" id="copybut2693" onclick="doCopy('code2693')">JavaScript<u> </u></a></span> </div> <div class="codebody" id="code2693">複製程式碼<br><br><br> 程式碼如下:<br><br> <br>//jq建立一個新的節點物件; <br>//例如:<div id=" mydiv" class="menu"></div> </div>var objNewDiv = $('<div>',{'id':'mydiv','class':'menu'}); <br>objNewDiv. html(123456); <strong>$('#hello').append(objNewDiv); </strong>console.log(objNewDiv); <br><img src="http://files.jb51.net/file_images/article/201301/201312195041619.png?201302195115" alt="jquery建立一個新的節點物件(自訂結構/內容)的好方法_jquery" > 結果: </div>