<script src="jquery-1.11.1.js"></script>
<script src="jquery-MrLv-1.11.1-min.js"></script>
<script>
$(function () {
//调用插件中的方法
//第一种制作方法
// $("button").on("click", function () {
// $("button").setColorRed();
// })
//第二种绑定方法
$("button").on("click", function () {
$.setColorRed($(this));
})
})
</script>
</head>
<body>
<button>按钮1</button>
<button>按钮2</button>
<button>按钮3</button>
<button>按钮4</button>
<button>按钮5</button>
<button>按钮6</button>
</body>
/**
* Created by Lenovo on 2016/9/17.
*/
//绑定到原型上,调用者是jquery对象
$.fn.setColorRed = function () {
this.css({"color":"red"});
}
//绑定到$上,调用者是$
$.setColorRed = function (e) {
e.css({"color":"red"});
}