<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 3.1">
<title>Document Title</title>
</head>
<script language="javascript">
function rrr(){
var a=document.createElement("INPUT");
a.setAttribute("type","button");
a.setAttribute("name","newname");
a.setAttribute("value","提交");
a.onclick=ttt;
document.body.appendChild(a);
}
function ttt(){
alert("我现在在点击新创建的按钮了!");
}
</script><body >
<form name="aaa">
<input type="button" value="show" onclick="rrr()">
</form>
<!-- Insert HTML here -->
</body>
</html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 3.1">
<title>Document Title</title>
</head>
<script language="javascript">
function rrr(){
var a=document.createElement("INPUT");
a.setAttribute("type","button");
a.setAttribute("name","newname");
a.setAttribute("value","提交");
a.onclick=ttt;
document.body.appendChild(a);
}
function ttt(){
alert("我现在在点击新创建的按钮了!");
}
</script><body >
<form name="aaa">
<input type="button" value="show" onclick="rrr()">
</form>
<!-- Insert HTML here -->
</body>
</html>
解决方案 »
- 关于(new Date()).getTime()的问题
- 【Ext小白】查询时如何把输入的条件提交到JSP,在JSP里如何获取呢?
- 求一个Jplayer的方法
- 用正则如何返回数组。
- 秀一下代码~~~~用javascript 实现从任意xml文件提取数据成层状显示
- 回车保存数据的问题。
- div.style.height=200px.但实际不止200,怎样取得实际的height?
- 当一个页面关闭(点击WINDOWS)的关闭按扭,再将该页面连接到另一个页面吗?可以吗?
- 还是IE的问题,请教各位大神,代码如下:
- 前端不用npm怎么做?
- 如何利用javascript创建checkbox?
- 用document.createElement("input")创建了一个按钮,怎么样赋予它的单击事件呢?
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是不能赋值的
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 3.1">
<title>Document Title</title>
</head>
<script language="javascript">
function rrr(){
var a=document.createElement("INPUT");
a.setAttribute("type","button");
a.setAttribute("name","newname");
a.setAttribute("value","提交");
a.onclick=function(){
alert("我现在在点击新创建的按钮了!");
};
document.body.appendChild(a);
}
</script><body >
<form name="aaa">
<input type="button" value="show" onclick="rrr()">
</form>
<!-- Insert HTML here -->
</body>
</html>