一个call,apply,bind的例子

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <script src="../js/jquery.min.js"></script>
        <div onclick="abc.bind(this)('red','#fff')">fffff</div>
        <div onclick="abc.call(this,'yellow','red')">fffff</div>
        <div onclick="abc.apply(this,['green','#fff'])">fffff</div>
        <script>
            function abc(color1,color2){
                this.style.backgroundColor=color1
                this.style.color=color2
            }
        </script>
    </body>
</html>

 一个call,apply,bind的例子

一个call,apply,bind的例子

 一个call,apply,bind的例子

一个call,apply,bind的例子

posted @ 2017-06-29 15:43  欲速不达  阅读(199)  评论(0编辑  收藏  举报