看板 Ajax 關於我們 聯絡資訊
請問一下 我使用js去控制application的 navigation bar 我在assets中的javascripts目錄裏頭加入一個common.js 程式碼如下 結果我看console.log 發現只有第一次開網頁會被呼叫 後面點了連結頁面重刷之後就不會再被呼叫了 另外如果我使用click事件 也只有第一次點會有效果 點了連結頁面重刷之後click也失效了 請問我有哪裡搞錯了嗎 $(document).ready( function() { console.log(this); $('.cls_nav_link').each( function() { if( $(location).attr('href') == $(this).prop('href') ) { $(this).parent().addClass('active') } else { $(this).parent().removeClass('active') } } ); } ) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.141.182 ※ 文章網址: http://www.ptt.cc/bbs/Ajax/M.1412134344.A.34D.html
qazwsx9006: 我猜是turbolink關係? 10/01 21:45