您的位置:首页 > Web前端 > JQuery

jQuery扩展命名空间(扩展方法)

2014-12-17 10:15 435 查看
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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐