0

我想用我的函数创建的覆盖层来编写双重提交预防setWaitLayer()。如何使用 jQuery 选择所有具有 setWaitLayer 函数的提交按钮,例如

<form>
    <input type="submit" onclick="setWaitLayer("Please Wait");maybe_some_other_stuff()">
</form>
<form>
    <input type="submit" onclick="alert('this is not disabled')">
</form>

并将其中包含 setWaitLayer 的那些 onclick 事件更改为:

onclick="alert('Form already sent'); return false"

有没有类似的东西

$('input[onclick^="setWaitLayer"]').on('click',function(){
   alert('Form already sent');
   return false;
});
4

2 回答 2

1

为什么不使用类或数据属性来识别它?

<input type="submit" onclick="setWaitLayer("Please Wait");maybe_some_other_stuff()" class="wait_submit">

然后你可以等待如下

$('input[type="submit"].wait_submit').on('click',function(){
   alert('Form already sent');
   return false;
});
于 2013-10-04T08:40:56.670 回答
0

试试看,

$('input[type="submit"]').on('click',function(){
   alert('Form already sent');
   return false;
});

更新

HTML

<form>
    <input type="submit" id="submitForm1" onclick="setWaitLayer('Please Wait');maybe_some_other_stuff()">
</form>
<form>
    <input type="submit" id="submitForm2" onclick="alert('this is not disabled')">
</form>

脚本

$('#submitForm2').on('click',function(){
   alert('Form already sent');
   return false;
});
于 2013-10-04T08:37:26.433 回答