试图弄清楚为什么此onclick函数仅触发一次-我希望它在第二次单击时再次更改CSS。
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
</head>
<body>
<input type="button" value="Change height" onclick="run()">
<div id="change" style="height: 200px;background-color: lightgrey"></div>
</body>
<script>
function run(){
i = document.getElementById("change");
if(i.style.height = "200px"){
i.style.height = "300px"
}
else if (i.style.height = "300px"){
i.style.height = "200px"
}
}
</script>
</html>