简易版的jquery插件

<style>
div{
width: 200px;
height: 200px;
background-color: pink;
}
</style>
</head>
<body>
<div></div>
<script src="jquery-1.12.4.js"></script>
<script src="jquery-bgColor.js"></script>
<script>

$(function () {
$("div").bgColor("red").width(400);
});

</script>


jquery-bgColor.js:
$.fn.bgColor = function (color) {
//this是一个jq对象
this.css("backgroundColor", color);
return this;
};

猜你喜欢

转载自www.cnblogs.com/lujieting/p/10110837.html