jquery插件范例代码
2023-09-14 09:00:19 时间
// 创建一个闭包 (function($) { // 插件的定义 $.fn.hilight = function(options) { debug(this); // build main options before element iteration var opts = $.extend({}, $.fn.hilight.defaults, options); // iterate and reformat each matched element return this.each(function() { $this = $(this); // build element specific options var o = $.meta ? $.extend({}, opts, $this.data()) : opts; // update element styles $this.css({ backgroundColor: o.background, color: o.foreground }); var markup = $this.html(); // call our format function markup = $.fn.hilight.format(markup); $this.html(markup); }); }; // 私有函数:debugging function debug($obj) { if (window.console && window.console.log) window.console.log('hilight selection count: ' + $obj.size()); }; // 定义暴露format函数 $.fn.hilight.format = function(txt) { return '<strong>' + txt + '</strong>'; }; // 插件的defaults $.fn.hilight.defaults = { foreground: 'red', background: 'yellow' }; // 闭包结束 })(jQuery);
相关文章
- 轻巧的jQuery提示框插件Tipso演示
- jquery photoClip支持手机端,PC端 本地裁剪图片后上传插件
- 超实用的jQuery淡入淡出焦点图插件 带3D相框
- jquery表单验证
- jQuery 2.0.3 源码分析 数据缓存
- 如何编写高效的jQuery代码
- 第一百八十五节,jQuery,Ajax 表单插件
- 第一百七十一节,jQuery,高级事件,模拟操作,命名空间,事件委托,on、off 和 one
- 网友Nicky分享jquery css3响应式图片轮播特效|jqueryschool-插件教程分享
- 2015-7-18(jQuery全屏滚动插件fullPage.js)
- jQuery滑动选取数值范围插件
- jQuery插件开发精品教程,让你的jQuery提升一个台阶
- 我的jQuery动态表格插件二
- JQuery模板插件-jquery.tmpl
- 基于jquery的上传插件Uploadify 3.1.1在MVC3中的使用
- 电子签章盖章之jQuery插件jquery.zsign
- jquery分页插件pagination.js的使用
- 支持模糊查询的替代html中select的jquery插件
- animation in Jquery used in ui5
- WhatsApp - jQuery 聊天插件
- jQuery UI 实例 - 移除 Class(Remove Class)
- js 分页插件(jQuery)
- Vue:简单使用像引用jQuery一样引用Vue
- 使用jquery实现省市二级列表
- 【Java】【jquery】ajax垃圾问题
- JQuery日记_5.13 Sizzle选择器(六)选择器的效率
- jquery 插件 起步代码
- jQuery中$(function(){})与(function($){})(jQuery)、$(document).ready(function(){})等的区别详细讲解
- jQuery 效果函数