我在下面有四种不同类型的提交按钮:
<form id="QandA" action="register.php" method="post">
<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' />
<input type='submit' name='submitVideoBtn' class='sbtnvideo' value='Upload' />
<input type='submit' name='submitAudioBtn' class='sbtnaudio' value='Upload' />
<input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" />
</form>
现在我在下面有一个函数,假设它可以处理单击提交按钮后发生的事情:
$(function() {
myClickHandler=function(e)
{
if (!validation())
return false;
if (!confirm("Are you sure you want to Proceed?" + "\n" ))
return false;
$.ajax({
url: "insertQuestion.php",
data: $("#QandA").serialize(),
async: false,
type: "POST"
});
return true;
};
$('#QandA').submit(myClickHandler);
});
现在,所有上述提交按钮都会触发上述事件。我只希望id="submitBtn"
提交按钮触发上述功能。我不希望其他提交按钮触摸此功能。我的问题是我该怎么做?
更新:
$(function() {
$('#submitBtn').click(function(){
myClickHandler=function(e)
{
if (!validation())
return false;
if (!confirm("Are you sure you want to Proceed?" + "\n" ))
return false;
$.ajax({
url: "insertQuestion.php",
data: $("#QandA").serialize(),
async: false,
type: "POST"
});
return true;
};
});
});