jQuery自定义插件
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/jquery-easyui-1.2.6/jquery-1.7.2.min.js"></script>
</head>
<body>
<script type="text/javascript">
jQuery.fun=function(){
alert("tt");
}
jQuery.fun();
jQuery.myPlugin={
sum:0,
getSum:function(arrObj){
for(var i in arrObj){
//这里直接定义的是对象的实例,所以this.sum不能换成sum
this.sum = this.sum + Number(arrObj[i]);
}
},
getAvg:function(){
},
retSum:function(){
return this.sum;
}
}
var data = [1,2,3,4,5,6,7,8];
jQuery.myPlugin.getSum(data);
alert(jQuery.myPlugin.retSum());
</script>
</body>
</html>