整理英文原版如下:
question:
I'm figuring out why this simple script is not working:
jQuery.noConflict(); jQuery(document).ready(function() { jQuery('.next_button a').trigger('click'); });
noConflict is necessary because I also load prototype/scriptaculous in this page.
If I replace .trigger('click') with another function (es: .css(...) this works well. Only triggering seems to go broken.
answer:
You can only trigger a click that jQuery has created. It's one of jQuery's cute little quirks.Use the trigger method AFTER you've established the click listener。
我用到這個答案解決了問題,大意是說:你只有在用jQuery創建click方法之后才能去觸發click函數,這是jQuery的一個小怪癖。在建立click監聽器之后再去使用trigger方法。
而我的代碼恰恰就是把click監聽器定義在了trigger函數之后,所以頁面重新加載的時候無法執行trigger中的click方法,按照這個說法更換了click監聽器的位置到trigger觸發器之前,就解決了問題。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com