首页 > 代码库 > jQuery $.extend $.fn.extend

jQuery $.extend $.fn.extend

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
(function() {
    $.extend({
        add:function() {alert(1)},
    });
    $.fn.extend({
        add:function(){alert(2)},
    })
})(jQuery)
$.add();
$("div").add();
</script>
</head>

<body>
<div></div>
</body>
</html>