当前位置: 代码迷 >> Web前端 >> jquery插件根本模板
  详细解决方案

jquery插件根本模板

热度:122   发布时间:2012-11-25 11:44:31.0
jquery插件基本模板
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script>

<script type="text/javascript">
(function($){
	$.fn.highlight = function(options){
		var defaults = {
			foreColor: "white",
			backColor: "deepskyblue"
		};
		
		var opts = $.extend({}, defaults, options || {});
		
		return this.each(function(){
			var self = $(this);
			self.css({
				"color": opts.foreColor, 
				"background-color": opts.backColor
		    });
		});
	};
})(jQuery);
</script>

<script type="text/javascript">
$(function(){
//	$(".highlight").highlight();
	$("label").highlight();
});
</script>
</head>

<body>
<label class="highlight">gggggggggggggggg</label>
<label>gggggggggggggggg</label>
<label class="highlight">gggggggggggggggg</label>
<label>gggggggggggggggg</label>
<label class="highlight">gggggggggggggggg</label>
<label>gggggggggggggggg</label>
<label class="highlight">gggggggggggggggg</label>
</body>
</html>


  相关解决方案