<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><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> <br> <br><p id="hello">Hello OSTools</p> <br> <br> <br> </div> <br><strong>JavaScript</strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="2693" class="copybut" id="copybut2693" onclick="doCopy('code2693')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code2693"> <br>//jq创建一个新的节点对象; <br>//例如:<div id="mydiv" class="menu"></div> <br>var objNewDiv = $('<div>',{'id':'mydiv','class':'menu'}); <br>objNewDiv.html(123456); <br>$('#hello').append(objNewDiv); <br>console.log(objNewDiv); <br> </div> <br><strong>结果</strong>: <br><img src="http://files.jb51.net/file_images/article/201301/201312195041619.png?201302195115" alt="jquery创建一个新的节点对象(自定义结构/内容)的好方法_jquery" > </div>