JavaScript click事件仅在InfoPath表单上第一次触发

时间:2013-04-16 17:51:43

标签: javascript jquery infopath2010

每次点击按钮时,我都会尝试按钮显示警告。目前,它只在我第一次点击时触发,我必须刷新页面才能使其再次运行。因为这是一个Submit和New按钮,所以我需要它能够保留表单值,如果它重新加载就会丢失。警报用于向用户提供反馈。这是我的代码:

$('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');
});

2 个答案:

答案 0 :(得分: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/

答案 1 :(得分: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