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 ...
随机推荐
- Solr与Mysql简单集成
Solr与Mysql数据库的集成,实现全量索引.增量索引的创建. 基本原理很简单:在Solr项目中注册solr的DataImportHandler并配置Mysql数据源以及数据查询sql语句.当我们通 ...
- java AES加密算法
package com.siro.tools; import javax.crypto.Cipher;import javax.crypto.spec.IvParameterSpec;import j ...
- information_schema中的三个关于锁的表
在5.5中,information_schema 库中增加了三个关于锁的表(MEMORY引擎):innodb_trx ## 当前运行的所有事务innodb_locks ## ...
- C# chart控件绘制曲线
在.NET中以前经常用GDI去绘制,虽然效果也不错,自从.NET 4.0开始,专门为绘制图表而生的Chart控件出现了,有了它,就可以轻松的绘制你所需要的曲线图.柱状图什么的了. using Syst ...
- mybatis中的变量#与$
ibatis中使用select top #num# * from tableName出现错误.由于初次用ibatis还不知道在它里边拼写SQL语句的一些规则,导致一些自认为很平常的SQL语句,在它这里 ...
- 大数据性能调优之HBase的RowKey设计
1 概述 HBase是一个分布式的.面向列的数据库,它和一般关系型数据库的最大区别是:HBase很适合于存储非结构化的数据,还有就是它基于列的而不是基于行的模式. 既然HBase是采用KeyValue ...
- 六种排序的C++实现
class SortNum { public: SortNum(); virtual ~SortNum(); void exchange(int& b,int& c);//交换数据 v ...
- android电池信息简介
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- 在Ubuntu下安装Apache
在Ubuntu下安装软件其实非常方便,Ubuntu提供了apt-get工具,可以使用该工具直接下载安装软件. 在Linux里,系统最高权限账户为root账户,而默认登录的账户并非root账户,例如不具 ...
- Eclipse中设置在创建新类时自动生成注释的方法
windows–>preference Java–>Code Style–>Code Templates code–>new Java files 编辑它 ${filecom ...