作业:构建网站 - 知识准备 - jQuery插件 - 颜色插件

什么是插件?

插件就是用来做扩展功能的
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>

在这里插入图片描述

使用插件
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章