[問題] 執行超連結以後jquery失效

看板Web_Design作者 (酣酣)時間11年前 (2015/02/11 15:49), 11年前編輯推噓3(304)
留言7則, 6人參與, 最新討論串1/1
小弟做了一個網頁包含了四個超連結 網頁:index.php 超連結1:index.php?page=A 超連結2:index.php?page=B 超連結3:index.php?page=C 超連結4:index.php?page=D 進入首頁(index.php),點超連結後(index.php?page=A), 網頁的jquery語法會失效,但按了重新更新後jquery又有效了 PS:我有用樣板引擎smarty 麻煩各位高手給小弟指點迷津或給個方向 這問題困擾好幾天了 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.35.130.39 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1423640989.A.671.html

02/11 15:59, , 1F
看不太懂....
02/11 15:59, 1F

02/11 16:05, , 2F
jquery語法會失效 有錯誤訊息嗎
02/11 16:05, 2F

02/12 00:52, , 3F
什麼語法…講清楚一點…
02/12 00:52, 3F

02/12 02:59, , 4F
你用到Ajax? 是的話有變動的元素event要重新bind
02/12 02:59, 4F
以下是我的程式碼 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>HomeGatWay</title> <link rel="shortcut icon" href="ext/favicon.ico"> <link rel="stylesheet" href="" rel="nofollow">http://fonts.googleapis.com/css?family=Open+Sans:300,400,700"> <link rel="stylesheet" href="ext/css/themes/default/jquery.mobile-1.4.5.min.css"> <link rel="stylesheet" href="templates/style/default.css"> <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.4.5.js"></script> </head> <body> <div data-role="page"> <div data-role="header" data-position="fixed" data-tap-toggle="false"> <a href="#nav-panel" class="jqm-navmenu-link ui-nodisc-icon ui-alt-icon ui-btn-left ui-btn ui-icon-bars ui-btn-icon-notext ui-corner-all" data-role="button" role="button">Menu</a> <h1><div class="top_user" style="float:right">page_main</div></h1> </div><!-- /header --> <div role="main" class="ui-content"> <div class="actionbar"> <div style="float:right;"> <nav> <a href="?page=roon&action=append">p1</a> <a href="?page=roon&action=edit&roonno=">p2</a> <a href="?page=roon&action=cancel&roonno=">p3</a> <a href="?page=roon&action=delete&roonno=">p4</a> </nav> </div> </div> </div><!-- /content --> <script> $(function(){alert('456');}); </script> </div><!-- /page --> </body> </html> 我用ie/chrome 測過 點P1~P4的超連結 都會有一個超連結點下去後alert('456');會執行不到 按F5重新更新後就會正常跳出alert('456'); 最後發現只要把 <script src="js/jquery.mobile-1.4.5.js"></script>這段拿掉就 正常了 ※ 編輯: e2755699 (114.35.130.39), 02/12/2015 11:26:02

02/12 11:57, , 5F
在<a>加上data-ajax="false" 試看看
02/12 11:57, 5F

02/12 11:58, , 6F
jquery mobile官方文件有說明Link的使用
02/12 11:58, 6F

02/12 13:08, , 7F
挖~好像有效耶 我找了超久
02/12 13:08, 7F
文章代碼(AID): #1KsmcTPn (Web_Design)