-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal_expand.html
More file actions
36 lines (32 loc) · 949 Bytes
/
global_expand.html
File metadata and controls
36 lines (32 loc) · 949 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery全局进行方法扩展</title>
<script src="../js/jquery-3.3.1.min.js" type="text/javascript" charset="UTF-8"></script>
<!--
$.extend(object)
* 增强JQeury对象自身的功能 $/jQuery
-->
<script>
//对全局方法扩展2个方法,扩展min方法:求2个值的最小值;扩展max方法:求2个值最大值
$.extend({
max:function (a, b) {
//返回两数中的较大值
return a >= b ? a : b;
},
min:function (a, b) {
//返回两数中的较小值
return a <= b ? a : b;
}
});
//返回两数中的较大值
var max = $.max(5, 10);
alert("max = " + max);
var min = $.min(1, 6);
alert("min = " + min);
</script>
</head>
<body>
</body>
</html>