<script type="text/javascript">
function obtn(){
alert(1)
}
document.getElementById("x").onclick=obtn;
</script>
8 回答
已采纳
陈士愚
TA贡献44条经验 获得超44个赞
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>单击事件 </title>
</head>
<body>
<form id="sts">
<div id="x">
<input id="alter" type="button" value="修改样式"> </div>
</form>
<script type="text/javascript">
function obtn() {
alert(1);
}
document.getElementById("x").onclick = obtn;
</script>
</body>
</html>可以执行,不清楚你的本地啥情况……
花亦飘零久
TA贡献1条经验 获得超0个赞
<head>
<script>
window.onload=function(){
document.getElementById("x").onclick = obtn;
};
function obtn(){alert(1);}
</script>
</head>添加回答
举报
0/150
提交
取消
