这是HTML结构,调用了setValue函数:<input type="button" value="设置默认值" onclick="setValue()" name="">这是js函数部分://control属性function setValue() { var label = document.getElementById("label"); var textbox = label.control; textbox.value = "213001";}我检查的时候试过,连alert都不起作用,应该是函数调用出错,但是实在找不出哪里错了,请各位帮忙看一下,谢谢O(∩_∩)O
1 回答
已采纳
stone310
TA贡献361条经验 获得超191个赞
你这种写法是,样式行间有调用函数;调用的函数里面又有获取样式;所以js代码只能放在</body>前面,而且不能放进window.onload;看一下是不是这方面的问题
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<input type="button" value="设置默认值" onclick="setValue()" name="" id="label">
<script>
function setValue() {alert("")}
</script>
</body>
</html>添加回答
举报
0/150
提交
取消
