test.js
//jQuery扩展命名空间:test
$.extend({ test: {} });
//test扩展方法
$.extend($.test, {
fun1: function () {
alert(1);
},
fun2: function (value) {
alert(value)
}
});
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication41.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/test.js"></script>
<script type="text/javascript">
$(function () {//调用
$.test.fun1();
$.test.fun2(2);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>