jquery自定义插件(颜色)

来源:互联网 发布:jsp java注释 编辑:程序博客网 时间:2024/06/04 19:24
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
;(function($){
jQuery.fn.extend({
"color":function(value){
return this.css("color",value);
}
});
})(jQuery);




$(function(){
alert($(".a").color());
$(".a").color("red");
})
</script>
</head>
<body>
<div class="a">red</div>
<div style="color: blue">blue</div>
<div style="color: green">green</div>
<div style="color: yellow">yellow</div>
</body>
</html>
0 0