; (function ($) {
$.fn.extend({
setTableStyle: function () {
$("tr", this).mouseover(function () {
$(this).css({ "backgroundColor": "yellow" }).siblings().css({ "backgroundColor": "white" });
});
},
clearTableStyle: function () {
$("tr", this).css({ "backgroundColor": "white" }).unbind();
}
})
})(jQuery);
<!-- 引入所需的js包 -->
<!-- 先引入JQuery主程序 -->
<script src="JQuery/jquery-2.0.0.js" type="text/javascript"></script>
<!-- 再引入自己编写的插件js包 -->
<script src="JQuery-tableStyle.js" type="text/javascript"></script>
$(function () {
$("#btnSet").click(function () {
$("#tbl1").setTableStyle();
});
$("#btnClear").click(function () {
$("#tbl1").clearTableStyle();
});
});