t327-1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
div{
width: 50px;
height: 50px;
background-color: lightskyblue;
}
</style>
<script src="../../js/jquery-3.5.1.js"></script>
<script src="../../js/jquery.color.js"></script>
<script>
$(function () {
$("div").click(function () {
$(this).animate({
"width":"150px",
"height":"150px",
"background-color":"red"
},1000);
});
});
</script>
</head>
<body>
<div></div>
</body>
</html>
t327-2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
div{
width: 100px;
height: 100px;
background-color: lightskyblue;
}
</style>
<script src="../../js/jquery-3.5.1.js"></script>
<script>
//$.getScript()
//优化后,动态加载js文件
$(function () {
$("div").click(function () {
$.getScript("../../js/jquery.color.js");
$(this).animate({
"width": "200px",
"height":"200px",
"background-color":"red"
},1000);
});
});
</script>
</head>
<body>
<div></div>
</body>
</html>