整理英文原版如下:
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。
我用到這個(gè)答案解決了問題,大意是說:你只有在用jQuery創(chuàng)建click方法之后才能去觸發(fā)click函數(shù),這是jQuery的一個(gè)小怪癖。在建立click監(jiān)聽器之后再去使用trigger方法。
而我的代碼恰恰就是把click監(jiān)聽器定義在了trigger函數(shù)之后,所以頁面重新加載的時(shí)候無法執(zhí)行trigger中的click方法,按照這個(gè)說法更換了click監(jiān)聽器的位置到trigger觸發(fā)器之前,就解決了問題。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com