<div class="codetitle"> <span><a style="CURSOR: pointer" data="87560" class="copybut" id="copybut87560" onclick="doCopy('code87560')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code87560"> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>createElement</title> <br><style type="text/css"> <BR>.warpper{ border:1px solid red; padding:8px;} <BR></style> <br><script type="text/javascript" language="javascript" src="JavaScript/jquery-1.6.1.min.js"></script> <br><script type="text/javascript" language="javascript"> <BR><!-- <BR>///动态创建一个div <BR>$(function(){ <BR>$('<div />',{ <BR>id:'test', <BR>text:"this is a div", <BR>"class":"warpper", <BR>click:function(){ <BR>var text=$(this).text(); <BR>alert(text); <BR>} <BR>}).appendTo("body"); <BR>}); <BR>//创建input:text <BR>$(function(){ <BR>$('<input />',{ <BR>type:"text", <BR>val:"input text somethings...", <BR>name:"userName" <BR>}).appendTo("body"); <BR>}); <BR>//创建input select <BR>$(function(){ <BR>var slt=$('<select />',{name:"country" }); <BR>$('<option />',{ <BR>val:"0", <BR>text:"请选择" <BR>}).appendTo(slt); <BR>$('<option>',{ <BR>val:"CN", <BR>text:"China", <BR>selected:"selected" <BR>}).appendTo(slt); <BR>$("body").append(slt); <BR>}); <BR>//创建radio <BR>$(function(){ <BR>$('<input />',{ <BR>type:"radio", <BR>name:"rdo", <BR>checked:"checked", <BR>val:"男" <BR>}).appendTo("body"); <BR>$('<label>',{ <BR>text:"男", <BR>}).appendTo("body"); <BR>$('<input />',{ <BR>type:"radio", <BR>name:"rdo", <BR>val:"女" <BR>}).appendTo("body"); <BR>$('<label>',{ <BR>text:"女" <BR>}).appendTo("body"); <BR>}); <BR>//creat checkbox <BR>$(function(){ <BR>$('<input />',{ <BR>type:"checkbox", <BR>name:"cbox", <BR>val:"1", <BR>checked:"checked" <BR>}).appendTo("body"); <BR>}); <BR>$(function(){ <BR>$('<input />',{ <BR>type:"file", <BR>name:"myfile" <BR>}).appendTo("body"); <BR>}); <BR>//--> <BR></script> <br> <br> <br><form> <br> <br> <br> </form> </div>