qq_慕移动6125882
2021-02-08 21:47
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var height=window.innerHeight;
var width=window.innerWidth;
var input=document.createElement("input");
input.type="button";
input.value="你好";
input.conclick="alerte()";
document.body.appendChild(input);
function alerte(){
alert(height+"和"+width);
}
</script>
</body>
</html>
13行onclick写成了conclick
input.conclick="alerte()";这行用下面的代替
input.onclick=alerte;
或者这样也行input.setAttribute("onclick","alerte()");
具体的原因我也不知道orz,不知道怎么解释
JavaScript进阶篇
469061 学习 · 22582 问题
相似问题