什麼是插件?
插件就是用來做擴展功能的
jQuery插件庫:http://www.jq22.com/
顏色插件
網址:https://www.bootcdn.cn/jquery-color/
animate動畫不會改變背景色,如果非要改,就要使用插件
下面的代碼試圖在移動時將方塊的背景色變爲綠色,但是失敗
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.div1{
width:300px;
height:300px;
background-color:red;
position:absolute;
left:0;
}
</style>
</head>
<body>
<input type="button" value="移動" id="lr">
<div class="div1"></div>
</body>
</html>
<script src="../JQuery/jquery-1.12.4.js"></script>
<script>
$(function(){
$('#lr').click(function(){
$('.div1').animate({
left:800,
width:50,
height:50,
backgroundColor:'green'
},2000);
});
});
</script>
使用插件