2013-04-16 167 views
1

我試圖讓按鈕在每次單擊該按鈕時顯示警報。目前,它僅在我第一次點擊時觸發,我必須刷新頁面才能使其再次運行。因爲這是「提交」和「新建」按鈕,所以我需要它能夠保留重新加載時將丟失的表單值。警報用於向用戶提供反饋。這是我的代碼:JavaScript點擊事件僅在InfoPath表單上第一次觸發

$('input[value="Submit and New"]').on('click', function(){ 
alert('The request form has been submitted successfully. To submit a new form for the same user, change the form values and click on either the "Submit" or "Submit and New" button'); 
}); 

回答

1

集點擊使用文檔,它應該正常工作

$(document).on('click','input[value="Submit and New"]', function(){ 
    alert('The request form has been submitted successfully. To submit a new form for the same user, change the form values and click on either the "Submit" or "Submit and New" button'); 
    }); 

http://jsfiddle.net/w4QWu/

0

你可能調用該函數加載文檔之前,試試這個:

$(document).ready(function(){ 
    $('input[value="Submit and New"]').on('click', function(){ 
alert('The request form has been submitted successfully. To submit a new form for the same user, change the form values and click on either the "Submit" or "Submit and New" button'); 
    } 
}) 

jsfiddle

相關問題