问答详情
源自:4-11 编程挑战

jquery-extend()到底有什么用啊?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        ul{
            width:100px;
            margin:10px auto;
        }
        li{
            height:30px;
            background-color:#0d638f;
            padding:1px;
            margin:1px 0;
            line-height:30px;
            text-align: center;
            color:#f0ad4e;

        }
        li:hover{
            cursor:pointer;
        }
    </style>
    <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../js/jquery-2.0.0.min.js"></script>


</head>
<body>
<ul id="ulTest">
    <li>我是第一个</li>
    <li>我是第二个</li>
    <li>我是第三个</li>
    <li>我是第四个</li>
</ul>

<script type="text/javascript">
    /*$(function(){
        $("li").bind("mouseover",function(){
            $(this).css("background-color","#fffccc")
        });
        $("li").bind("mouseout",function(){
            $(this).css("background-color","#0d638f");
        });
    })*/
 $(function(){
        var oldcolor="#0d638f";
       $.extend({
           "focuse":function(obj,color){
                   $(obj).mouseover(function(){$(this).css("background",color)});
                   $(obj).mouseout(function(){$(this).css("background",oldcolor)});
               }
        });
    });
    $(function(){
            $.focuse($("li"),"blue")
    })




</script>
</body>
</html>


提问者:web_東 2018-04-27 12:56

个回答

  • 好吃的蛋包饭
    2018-08-14 22:55:44

    用来拓展对象的,前面的课讲过

  • 乏心
    2018-07-15 23:12:44

    自定义想要的插件啊