JQuery Plugin 1 - Simple Plugin
1. How do you write a plugin in jQuery?
You can extend the existing jQuery object by writing either methods or functions.
1) Writing a custom jQuery method
jQuery methods are defined by extending the jQuery.fn object with your method name.
$.fn.extend({
//Only Test
MasterTest: {
alertTest: function () {
alert('Welcome Master HaKu!');
}
}
});
call the method
$(document).ready(function () {
$('#btnAlert').click(function () {
$.fn.MasterTest.alertTest();
});
});
eg:
/*
JQuery Plugin - custom jQuery method
*/ $.fn.appendHtml = function (destId, appendId) {
$(destId).append('<div>Add Text: ' + $(appendId).html() + '</div>');
};
call the method
$.fn.appendHtml('#result', '#myText');
2) Writing a custom jQuery function
eg:
/*
JQuery Plugin - custom jQuery function
*/ $.appendHtml = function(destId, appendId) {
$(destId).append('<div>Append: ' + $(appendId).html() + '</div>');
};
call the function
$.appendHtml('#result', '#myText');
JQuery Plugin 1 - Simple Plugin的更多相关文章
- 创建一个dynamics 365 CRM online plugin (六) - Delete plugin from CRM
我们之前都学习到怎么添加,debug还有update plugin. 今天带大家过一下怎么从CRM instance当中删除plugin. 首先让我们打开Settings -> Customiz ...
- [译] EXTENDING JQUERY – 2.2 A simple plugin
2.2 一个简单的插件示例 jQuery 插件能做任何事情,这个已经由浩如烟海的各类第三方插件如证明.小到只影响一个元素,大到改变多个元素的外观和行为,jQuery 的各种功能等你来扩展. 2.2.1 ...
- 7 Best jQuery & JavaScript PDF Viewer plugin with examples
In this Post we are providing best jQuery PDF viewer plugin & tutorial with examples.Due to popu ...
- jQuery笔记之Easing Plugin
jQuery easing 使用方法首先,项目中如果需要使用特殊的动画效果,则需要在引入jQuery之后引入jquery.easing.1.3.js<script type="text ...
- 在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”的解决方案
eclipse在其POM文件的一处提示出错如下: Plugin execution not covered by lifecycle configuration: org.apache.maven.p ...
- 解决 在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”
eclipse在其POM文件的一处提示出错如下: Plugin execution not covered by lifecycle configuration: org.apache.maven.p ...
- Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”
myeclipse在其POM文件的一处提示出错如下: Plugin execution not covered by lifecycle configuration: org.apache.maven ...
- "Loading a plug-in failed The plug-in or one of its prerequisite plug-ins may be missing or damaged and may need to be reinstalled"
The Unarchiver 虽好,但存在问题比我们在mac上zip打包一个软件xcode, 然后copy to another mac, 这时用The Unarchiver解压缩出来的xcode包不 ...
- bootstrap的导航改造
在使用bootstrap制作后台时用到了响应式导航条,其中dropdown组件更是用的比较多,用的多需要点击的就多,dropdown默认鼠标左键单击才展开,如果使用鼠标放上去(hover)就展开则会省 ...
随机推荐
- Android Message和obtainMessage的区别
类概述 定义一个包含任意类型的描述数据对象,此对象可以发送给Handler.对象包含两个额外的int字段和一个额外的对象字段,这样可以使得在很多情况下不用做分配工作. 尽管Message的构造器是公开 ...
- java.lang.Throwable 异常/深入
有几个现象是需要总结的: -------------------------------------- 在java语言中,错误类的基类是java.lang.Error,异常类的基类是java.lang ...
- [FIX BUG]获取theme中自定义textColor时报的错误
我在Fragment中inflate它都可以,可是一旦使用ListView来inflate就会报错,说找不到我自定义的attr!研究了半天发现是我的inflate的context有问题: view = ...
- ylbtech-Model-Account(通用账户模块设计)
ylbtech-DatabaseDesgin:ylbtech-Model-Account(通用账户模块设计) ylbtech-Model-Account(通用账户模块设计) 1.A,数据库关系图(Da ...
- HTTP协议中的长连接和短连接(keep-alive状态)
什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待在同 ...
- Android访问权限大全
android.permission.ACCESS_CHECKIN_PROPERTIES 允许读写访问”properties”表在checkin数据库中,改值可以修改上传( Allows read/w ...
- gcc编译器基本命令和vi编辑器2
!1 os fen时 看电影 聊天.支持多核处理器 分任务 已经绝迹cpu Trobe c 分任务操作系统三大组成部分内核,命令解释器(shell外壳),文件系统2修改文件日期或(创建文件)命令:to ...
- pci 记录
用linux 下的sysfs可以方便的查看pci设备的配置和资源. 所有的pci设备在/sys/bus/pci/device 下面看到 pci配置空间对应的是设备对应的目录下的config文件,是二进 ...
- 高精度+搜索+质数 BZOJ1225 [HNOI2001] 求正整数
// 高精度+搜索+质数 BZOJ1225 [HNOI2001] 求正整数 // 思路: // http://blog.csdn.net/huzecong/article/details/847868 ...
- matlab的&和&&操作
A&B(1)首先判断A的逻辑值,然后判断B的值,然后进行逻辑与的计算.(2)A和B可以为矩阵(e.g. A=[1 0],B=[0 0]).A&&B(1)首先判断A的逻辑值,如果 ...