我在製作網站時遇到了很大麻煩。出於某種原因,無論我做什麼,我都無法獲得JavaScript。有什麼我錯過'啓用'這個?Javascript並不在我的網站工作
例如,我完全抄襲了一件非常簡單的事情。 https://codepen.io/thetallweeks/pen/boinE
在測試文件是這樣的:
<html>
<head>
<script>
$("#button").click(function() {
$('.transform').toggleClass('transform-active');
});
</script>
<style>
.box {
background-color: #218D9B;
height: 100px;
width: 100px;
}
.transform {
-webkit-transition: all 2s ease;
-moz-transition: all 2s ease;
-o-transition: all 2s ease;
-ms-transition: all 2s ease;
transition: all 2s ease;
}
.transform-active {
background-color: #45CEE0;
height: 200px;
width: 200px;
}
</style>
</head>
<body>
<div class="box transform">
</div>
<input type="button" id="button" value="Click Me"></input>
</body>
</html>
然而,按鈕不做任何事情在我的測試文件。 我做錯了什麼?
那是因爲你jQuery缺失 –
'$()'不是通用JavaScript,它是jQuery。你安裝了jQuery庫包嗎? – Claies