JQuery Plugin 2 - Passing Options into Your Plugin
overriding the default options with user-supplied options and the jQuery extend() method
eg:
$.fn.pulse = function (options) {
// Merge passed options with defaults
var opts = $.extend({}, $.fn.pulse.defaults, options);
return this.each(function () {
// Pulse
for (var i = 0; i < opts.pulses; i++) {
$(this).fadeTo(opts.speed, opts.fadeLow).fadeTo(opts.speed, opts.fadeHigh);
}
// Reset to normal
$(this).fadeTo(opts.speed, 1);
});
};
// Pulse plugin default options
$.fn.pulse.defaults = {
speed: "slow",
pulses: 2,
fadeLow: 0.2,
fadeHigh: 1
};
call the plugin
// Override only one option
$('#myText1').pulse({ pulses: 6 }); // Override all options
$('#myText2').pulse({ speed: "fast", pulses: 10, fadeLow: 0.3, fadeHigh: 0.8 });
JQuery Plugin 2 - Passing Options into Your Plugin的更多相关文章
- GBin1插件推荐之马可波罗(Marco Polo),jQuery的自动补齐插件 - Autocomplete Plugin
让我们Google一下"jQuery autocomplete plugin"(jquery自动补齐插件).在过去的4年中,我已经Google了很多次这个组合了.然而结果并没有变化 ...
- jQuery file upload callback options
autoUpload By default, files added to the widget are uploaded as soon as the user clicks on the star ...
- IDEA报错Plugin "XXX" was not loaded: required plugin "Java EE: EJB, JPA, Servlets" is disabled.
Java项目转Web项目 把java项目转成web项目时,发现Facets点击+号没有出现web选项. 经查询发现是插件没有正常加载导致的. 解决方案 1.没找到其他原因,重启即可. 2.我的是插件没 ...
- Visual Studio 2013 always switches source control plugin to Git and disconnect TFS
A few days ago, I've been facing a strange behavior with Visual Studio 2013. No matter what solu ...
- 卡片抽奖插件 CardShow
这个小项目(卡片秀)是一个卡片抽奖特效插件,用开源项目这样的词语让我多少有些羞愧,毕竟作为一个涉世未深的小伙子,用项目的标准衡量还有很大差距.不过该案例采用 jQuery 插件方式编写,提供配置参数并 ...
- 响应式卡片抽奖插件 CardShow
GitHub: https://github.com/nzbin/CardShow/ Demo: https://nzbin.github.io/CardShow/ 前言 这个小项目(卡片秀)是一个卡 ...
- webpack学习笔记丁点积累
webpack是什么? https://webpack.js.org/concepts/ https://code.tutsplus.com/tutorials/introduction-to-web ...
- Jquery Plugin模版
1. [代码][JavaScript]代码 01// remember to change every instance of "pluginName" to the name o ...
- How to Create a Basic Plugin 如何写一个基础的jQuery插件
How to Create a Basic Plugin Sometimes you want to make a piece of functionality available throughou ...
随机推荐
- Oracle 课程九之绑定变量
课程目标 完成本课程的学习后,您应该能够: •变量绑定的目的 •父子游标 •游标共享 •绑定窥探 •SQL语句处理流程 •硬解析.软解析.软软解析 •变量绑定的应用场景 1.游标 游标可以理解为S ...
- #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)宏的运行机理:1. ( (TYPE *)0 ) 将零转型为TY ...
- Pacman主题下给Hexo增加简历类型
原文 http://blog.zanlabs.com/2015/01/02/add-resume-type-to-hexo-under-pacman-theme/ 背景 虽然暂时不找工作,但是想着简历 ...
- iE6、7、8、9、10、11兼容的Cookie
<%@ Master Language="C#" Debug="true" AutoEventWireup="true" Inheri ...
- OpenGL开发时,fatal error C1083: 无法打开包括文件:“gl\glut.h”: No such file or directory
本人使用的是vs2012,编写一个简单的opengl程序,运行的时候总是提示: fatal error C1083: 无法打开包括文件:“gl/glut.h”: No such file or dir ...
- mybatis中的变量#与$
ibatis中使用select top #num# * from tableName出现错误.由于初次用ibatis还不知道在它里边拼写SQL语句的一些规则,导致一些自认为很平常的SQL语句,在它这里 ...
- 滑动菜单栏开源项目SlidingMenu的使用
一.SlidingMenu简介相信大家对SlidingMenu都不陌生了,它是一种比较新的设置界面或配置界面的效果,在主界面左滑或者右滑出现设置界面效果,能方便的进行各种操作.很多优秀的应用都采用了这 ...
- golang学习遭遇错误原因分析续
7. error: reference to field ‘Printf’ in object which has no fields or methods f.Printf("%v&quo ...
- PHP 正则表达式总结
可以用字符作为一个通配符来代替除换行符(\n)之外的任一个字符.例如,正则表达式:.at可以与"cat"."sat"."#at"和" ...
- C/C++:类模板
类模板就是为类声明一种模板,使得类中的某些数据成员,或某些成员函数的参数,又或者是某些成员函数的返回值可以取任意的数据类型,包括基本数据类型和自定义数据类型. 类模板的声明形式如下: template ...