jquery插件
来源:互联网 发布:阿里云配置二级域名 编辑:程序博客网 时间:2024/05/18 22:52
http://www.cnblogs.com/playerlife/archive/2012/05/11/2495269.html
jquery插件代码
(function($) {var methods = {init: init,show: show}$.fn.myPlugin = function(method, options) {$.extend($.fn.myPlugin.defaults, options);if (methods[method]) { return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); } else if (typeof method === 'object' || ! method) {return methods.init.apply( this, arguments); } else {$.error( 'Method ' + method + ' does not exist on jQuery.myPlugin' ); }}function init(options) {return this.each(function() {var $this = $(this);$this.css('border', '1px solid red');$this.css('width', defaults.width);});};function show(options) {return this.each(function() {var $this = $(this);$this.css('width', defaults.width);});}var defaults = $.fn.myPlugin.defaults = {width:'100px'}})(jQuery);html代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><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" src="myPlugin.js"></script><script type="text/javascript">$(function() {$('#panel').myPlugin({width:'200px'}).css('height', '40px');$('#panel').myPlugin('show', {width:'500px'});})</script></head><body><div id="panel">11</div></body></html>
0 0
- jquery插件
- jquery 插件
- jQuery插件
- jquery 插件
- Jquery插件
- jquery 插件
- JQUERY 插件
- jquery 插件
- jquery插件
- jQuery插件
- jquery 插件
- JQuery插件
- Jquery插件
- jQuery插件
- JQuery插件
- jquery 插件
- Jquery 插件
- jQuery插件
- javaScript实现的前台分页
- poj 3304 判断是否有与所有线段相交的直线
- 通过Spring获取指定路径下的class
- linux runtime pm机制的深入理解
- 有5名学生保存在结构体数组中,编程按学生的成绩升序排序,按学生的姓名降序排序,按年龄从低到高排序
- jquery插件
- BOJ 438 田田的公司
- 健康和很久很久好国防生的 水电费
- 上传速度 、已用时间、预计剩余时间 上传资源时 上传文件大小,已上传大小 进度%
- Delphi 函数参数修饰中的var 、out和const
- hdu2157
- html5 更新图片颜色
- cocos2d-x3.0中bezier曲线的分析
- Unreal里的动画