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>
本文展示了如何在ASP.NET页面中使用jQuery扩展方法,并通过实例详细说明了jQuery扩展命名空间、定义方法以及在实际开发中的应用。
168

被折叠的 条评论
为什么被折叠?



