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 ...
随机推荐
- linux笔试
在对linux基本知识的归纳总结之后,这里是一份linux的测试题.希望能帮助大家复习和熟悉linux知识. 一.选择题 1.cron 后台常驻程序 (daemon) 用于: A. 负责文件在网络中 ...
- POJ 1173 Find them, Catch them
题意:有两个帮派,每个人只属于一个帮派,m次操作,一种操作告诉你两个人不是一个帮派的,另一种操作问两个人是不是在一个帮派. 解法:并查集+向量偏移.偏移量表示和根节点是不是同一帮派,是为0,不是为1. ...
- memmove函数
写一个函数,完成内存之间的拷贝 void* mymemcpy( void *dest, const void *src, size_t count ) { char* pdest = static_c ...
- Slalom
题意: 有n个宽度为w的门,给出门的左端点的水平位置x和高度y,和恒定的垂直速度,现有s个速度,求能通过这n个门的最大速度. 分析: 二分速度判断 #include <map> #incl ...
- HDU-4882 ZCC Loves Codefires
http://acm.hdu.edu.cn/showproblem.php?pid=4882 ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Ot ...
- 在ASM中移动数据文件
实验目的:在ASM存储环境下,要删除一个磁盘组,从而将磁盘组中的数据文件移动到另外一个磁盘组中. 查看数据文件存放的位置: SQL> select file#,name from v$dataf ...
- Codeforces Round #361 (Div. 2)
A 脑筋急转弯 // #pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream&g ...
- oracle 字符集转换:AL32UTF8->ZHS16GBK
select userenv('language') from dual; --修改Oracle数据库字符集为ZHS16GBK : SQL>conn / as sysdba; SQL>sh ...
- homework-01 "最大子数组之和"的问题求解过程
写在前面:我的算法能力很弱,并且也是第一次写博文,总之希望自己能在这次的课程中学到很多贴近实践的东西吧. 1.这次的程序是python写的,这也算是我第一次正正经经地拿python来写东西,结果上来说 ...
- Spring MVC SimpleUrlHandlerMapping example
In Spring MVC application, the SimpleUrlHandlerMapping is the most flexible handler mapping class, w ...