jquery 對css和js的匯入和運用

蓯芯開矢發表於2024-11-09

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="css/樣式.css" />
<script type="text/javascript" src="js/jquery-3.7.1.js" ></script>
<script type="text/javascript" src="js/功能.js" ></script>
</head>
<body>
<div>
<h1>玉溪農業職業學院</h1>
<p>資訊電氣工程學院</p>
<button>按鈕</button>
<hr />
</div>
</body>
</html>

css部分

h1{
background-color: blueviolet;
font-size: 40px;
color: coral;
}
p{
background-color:aquamarine;
font-size: 30px;
color: darkgoldenrod;
}
button{
width: 100px;
height: 50px;
}
div{
background-color: black;
}

js部分

$(document).ready(function(){
$("button").hover(function(){
$("div").css("background-color","aliceblue")
},function(){
$("div").css("background-color","aqua")

})
$("button").dblclick(function(){
$("h1").css("background-color","crimson")
})

})

相關文章