JQuery方法扩展
第一种 extend
<!-- extend 扩展jQuery,其实就是增加一个静态方法 --> 定义:
$.extend({
sayHello:function(name)
{
alert('Hello, '+(name?name:'XXXX')+' !')
}
}); 调用:
$(function(){
$.sayHello();
$.sayHello('Zhangsan');
});
第二种 $.fn
<!-- $.fn 给JQuery对象,增加方法 --> 定义:
$.fn.Red = function(){
this.each(function(){
$(this).append(' '+$(this).attr('href'));
}); return this.css('color','red');
} 调用:
$(function(){
$("a").Red().css('color','gray');
});
JQuery方法扩展的更多相关文章
- JS,JQuery的扩展方法
转 http://blog.csdn.net/tuwen/article/details/11464693 //JS的扩展方法: 1 定义类静态方法扩展 2 定义类对象方法扩展 ...
- 封装jQuery Validate扩展验证方法
一.封装自定义验证方法-validate-methods.js /***************************************************************** j ...
- Jquery自定义扩展方法(二)--HTML日历控件
一.概述 研究了上节的Jquery自定义扩展方法,自己一直想做用jquery写一个小的插件,工作中也用到了用JQuery的日历插件,自己琢磨着去造个轮子--HTML5手机网页日历控件,废话不多说,先看 ...
- jquery validate扩展验证方法
/***************************************************************** jQuery Validate扩展验证方法 (linjq) *** ...
- jquery中方法扩展 ($.fn & $.extend) 学习笔记
A.$.fn 1.$.fn.method() 函数为jQuery对象扩展一个属性和方法(主要用于扩展方法) :method 为自定义方法名 ($.fn 等效 $.prototype) $.fn.bor ...
- 为Jquery类和Jquery对象扩展方法
转:https://www.cnblogs.com/keyi/p/6089901.html jQuery为开发插件提拱了两个方法,分别是: JavaScript代码 jQuery.fn.extend( ...
- jQuery插件扩展方法
jQuery为扩展插件提拱了两个方法,分别是: jQuery.extend(object) —— 给jQuery对象添加方法. jQuery.fn.extend(object) —— 为扩展jQuer ...
- 扩展Jquery方法创建LigerUI Grid
///** //*封装jquery get请求ajax //*author:叶明龙 //*time:2012-12-10 //*/ function getAjax(url, para, fn) { ...
- jQuery扩展$.fn、$.extend jQery命名方法扩展 练习总结
<script> $.fn.hello = function(){ //扩展jQuery实例的自定义方法,基于$.fn的jq方法扩展 this.click(function(){ ...
随机推荐
- uva 10056 - What is the Probability ?(概率)
题目连接:uva 10056 - What is the Probability ? 题目大意:给出n和p以及m,表示有n个人在丢色子, 谁先丢到某个值就表示胜利,每个人丢到的胜利数值的概率都为p,问 ...
- C#中的Collection 3
IList<T> 和 ICollection<T> 最重要的一些类型 List<T>: Encapsulates[T], like array, but also ...
- POJ3928、LA4329【树状数组】
借此题试验一下各种做法的效果~ 这题为ACM2008北京站某题,介于简单与中等之间,做出来,罚时不多基本可以铜了,所以这样的题还必须得会,进阶之路. add(a[i]+1,1)这样处理之后,再用sum ...
- CarDAQ-Plus
Overview CarDAQ-Plus is the most validated and accepted J2534 device in the world. It has been on th ...
- Slony-I的限制
限制如下: http://slony.info/documentation/limitations.html Slony-I does not automatically replicate •Cha ...
- CSS 强制换行和禁止换行学习
强制换行 1.word-break: break-all; 只对英文起作用,以字母作为换行依据. 2.word-wrap: break-word; 只对英文起作 ...
- cdoj 80 Cube 水题
Cube Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...
- C#的WinForm中制作饼状图和柱状图
using System; using System.IO;//用于文件存取 using System.Data;//用于数据访问 using System.Drawing;//提供画GDI+图形的基 ...
- JBoss提供的常用的对称加密算法
package com.test.resteasy; import java.io.File; import java.net.MalformedURLException; import java.n ...
- C语言阶乘和求闰年
#include<stdio.h> void main(){ int i,a,s=1; scanf("%d",&a); for(i=1;i<=a;i++) ...