我正在学习 javascript,我对创建元素感到震惊。它在任何浏览器中都不起作用。这是我的代码:
<body>
<div id="cont">
<script type="text/javascript">
function hi()
{
alert("hi");
}
function replace()
{
var a=document.getElementById('cont');
var b=new Element("form",{name:"pnrForm",action:"\frame.html",method:"post"});
var c=new Element("input",{name:"lccp_trnname",type:"text",id:"lccp_trnname",size:"15",maxlength:"15",alt:"Train Name/Number"});
var d=new Element("input",{type:"image",name:"getIt",src:"button-get-pnr.png",align:"middle"});
b.appendChild(c);
b.appendChild(d);
a.appendChild(b);
}
replace();
hi();
</script>
</div>
</body>