<script language="javascript">
function rrr(){
var a=document.createElement("INPUT");
a.setAttribute("type","button");
a.setAttribute("name","newname");
a.setAttribute("value","提交");
a.onclick=ttt;
//或者
a.onclick=function(){
alert('我被单击了');
}
document.body.appendChild(a);
}
function ttt(){
alert("我现在在点击新创建的按钮了!");
}
</script>
function rrr(){
var a=document.createElement("INPUT");
a.setAttribute("type","button");
a.setAttribute("name","newname");
a.setAttribute("value","提交");
a.onclick=ttt;
//或者
a.onclick=function(){
alert('我被单击了');
}
document.body.appendChild(a);
}
function ttt(){
alert("我现在在点击新创建的按钮了!");
}
</script>
var a=document.createElement("<INPUT type=button name=newname value=提交>");
a.onclick = ttt;
document.body.appendChild(a);
}
function ttt(){
alert("我现在在点击新创建的按钮了!");
}带 name 的对象必须在createElement的时候就把name创建好, 通过a.name是不能赋值的