這個腳本爲什麼不起作用?設置風格不起作用?
<!DOCTYPE html>
<html>
<head>
<title>Hello StackOverflow!</title>
</head>
<body>
<div id="testing">
<p>Bladybla</p>
</div>
<script>
var one = window.innerWidth;
var two = 5;
var three = one/two;
var four = '"' + Math.round(three) + "px" + '"';
document.getElementById("testing").style.marginTop = four;
</script>
</body>
</html>
當我把var four
之間的警報和document.getElementById
是計算權值。問題出在.style.marginTop =
。它不打印計算的值。爲什麼?
在此先感謝Jaapyse!
它終於沒有工作! THANX! – Jaapyse
歡迎您:) – karaxuna