jquery 自定义函数方法
来源:互联网 发布:黑马java 全套百度云 编辑:程序博客网 时间:2024/06/04 18:54
总结:
* jQuery中添加自定义或函数方法1,如 $.fn.extend({'aa':function(){}}) 或 jQuery.fn.aa=function(){}, 这种调用时就得这样,$("#**").aa()
*jQuery中添加自定义或函数方法2,如$.extend({'aa':function(){}}),这种调用时就是这样$.aa()
* jQuery中添加自定义或函数方法3,(只是在前2种方法的基础上添加了参数处理,严格来说不算一种jQuery 自定义方法)如: $.myFuncThree("www.baidu.com",'hello',myFuncThreeCB);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<
html
>
<
head
>
<
meta
charset="utf-8" />
<
title
></
title
>
</
head
>
<
body
>
<
input
type="button" value="按钮" id="myBtn" >
</
body
>
<
script
src="js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></
script
>
<
script
type="text/javascript">
$(function(){
})
/**
* jQuery中添加自定义或函数方法1,如$.fn.extend({'aa':function(){}})或jQuery.fn.aa=function(){},这种调用时就得这样,$("#**").aa()
*/
jQuery.fn.myFuncOne=function(){
alert("我的自定义jquery方法1");
}
jQuery.fn.extend({
'myFuncFour':function(){
alert("我的自定义jquery方法4");
}
})
/**
* jQuery中添加自定义或函数方法2,如$.extend({'aa':function(){}}),这种调用时就是这样$.aa()
*/
jQuery.extend({
'myFuncTwo':function(){
alert("我的自定义jquery方法2");
}
})
/**
* jQuery中添加自定义或函数方法3,如 $.myFuncThree('/post/getsecurejsonpost',{}, function(data) {});
*/
$.myFuncThree = function(url, data, successCB){
alert("我的自定义jquery方法3,参数:"+url);
if(successCB){//回调
successCB(url);
}else{
alert("没有回调");
}
}
function myFuncThreeCB(url){
alert("myFuncThreeCB+"+url)
}
/*
* 测试按钮
*/
$("#myBtn").click(function(){
$("#myBtn").myFuncOne();
$("#myBtn").myFuncFour();
$().myFuncTwo();
$.myFuncThree("www.baidu.com",'hello',myFuncThreeCB);
$.myFuncThree("www.baidu.com",'hello');
})
</
script
>
</
html
>
0 0
- jQuery 自定义函数方法
- jquery自定义函数方法
- jquery自定义函数方法 .
- jquery 自定义函数方法
- jQuery中添加自定义或函数方法
- jQuery 中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jquery自定义函数的多种方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- jQuery中添加自定义或函数方法
- API管理,改变云计算、大数据和物联网的游戏规则
- OGNL与ValueStack(VS)-N语法top语法
- 百炼4106:出现两次的字符-Characters Appearing twice
- 学习笔记——Java
- 常用排序算法
- jquery 自定义函数方法
- 数放入数组输出数
- poj----Game Prediction
- 计算机操作系统(第四版)第一章习题
- 基于 Django1.10 文档的深入学习(29)——Built-in Views 之 static.serve()
- 括号匹配(二)
- 关于出现Intellij idea jsp web cannot resolve method getParameter(java.lang.String)
- 编码练习——Java-1-基础
- 个人资产盘点