jQuery jquery.color.js 背景颜色支持动画
时间:12-20来源:作者:点击数:
<!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>
div {
width: 100px;
height: 100px;
background-color: black;
}
</style>
<script src="jquery-3.4.1.js"></script>
<script>
$(function () {
$('button').on('click', function () {
$('div').animate({'background-color': 'red', 'width': 200}, 2000, function () {
alert('动画结束');
});
})
})
</script>
</head>
<body>
<button>变色</button>
<div></div>
</body>
</html>
<!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>
div {
width: 100px;
height: 100px;
background-color: black;
}
</style>
<script src="jquery-3.4.1.js"></script>
<!-- 只需要导入即可支持,无需任何改动 -->
<script src="jquery.color.js"></script>
<script>
$(function () {
$('button').on('click', function () {
$('div').animate({'background-color': 'red', 'width': 200}, 2000, function () {
alert('动画结束');
});
})
})
</script>
</head>
<body>
<button>变色</button>
<div></div>
</body>
</html>