AJAX -- jQuery.history 的完整範例
AJAX簡介方法jQueryREST問與答上一頁問題搜尋問題訊息相關網站參考文獻最新修改簡體版English |
專案下載:jqhistory.zip 網頁:jqhistory.htm<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>jQuery History Plugin Ajax Sample</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.history.js"></script> <script type="text/javascript" src="ajax.js"></script> <style type="text/css"> #content { border: 1px #666 solid; width: 300px; height: 300px; padding:0.5em; } </style> </head> <body> <h1>jQuery History Plugin Ajax Sample</h1> <div id="ajax-links"> <ul> <li><a href="#1">load 1.html</a></li> <li><a href="#2">load 2.html</a></li> <li><a href="#3">load 3.html</a></li> </ul> <div id="content"></div> <hr /> </div> <p>[<a href="../">All samples</a>] [<a href="http://github.com/tkyk/jquery-history-plugin">Project home</a>] </p> </body> </html> 程式:ajax.jsjQuery(document).ready(function($) { function load(num) { $('#content').load(num +".html"); } $.history.init(function(url) { load(url == "" ? "1" : url); }); $('#ajax-links a').live('click', function(e) { var url = $(this).attr('href'); url = url.replace(/^.*#/, ''); $.history.load(url); return false; }); }); 說明:jQuery(function($) 的意義。 Example: Uses both the shortcut for $(document).ready() and the argument to write failsafe jQuery code using the $ alias, without relying on the global alias. jQuery(function($) { // Your code using failsafe $ alias here... }); |
page revision: 4, last edited: 03 Dec 2010 01:35
Post preview:
Close preview