Jquery 我希望上传按钮不触发功能

Jquery 我希望上传按钮不触发功能,jquery,html,Jquery,Html,以下是处理正常提交按钮的功能: <script type="text/javascript"> $(function() { myClickHandler=function(e){ if (!validation()) return false; if (!confirm("Are you sure you want to Proceed?" + "\n" ))

以下是处理正常提交按钮的功能:

<script type="text/javascript">                 
   $(function() {
      myClickHandler=function(e){
        if (!validation())
            return false;    
        if (!confirm("Are you sure you want to Proceed?" + "\n" ))
            return false;    
        return true;
    };  
    $('#QandA').submit(myClickHandler);
});

</script>
HTML(#QandA表格):


问题是您将
myClickHandler()
附加到所有提交按钮,包括视频、音频和图像提交按钮


仅将其附加到问题所在的
#submitBtn

,我尝试执行
$('#submitBtn')。submit(myClickHandler)但这不起作用尝试$('submitBtn')。单击(myClickHandler(e))我尝试通过替换“$('QandA')来创建代码行。提交(myClickHandler);”上载按钮不会触发函数,这很好,但是如果我单击
submitdetails
按钮,它不会触发函数。尝试重构一下代码,我会将
myClickHandler
移动到jQuery init之外的标准
函数
,并移动$()。单击jquery初始化。我的问题中包含了一个更新。我还没有测试过更新代码,但是在我测试之前,你能评论一下更新中的代码重构在你看来是否正确吗。我只是想确认一下我把它和你说的是一致的
function insertQuestion(form) { 
    var $image = $("<td class='image'></td>"); 
    var $fileImage = $("<form action='imageupload.php' method='post' 
                    enctype='multipart/form-data' target='upload_target_image'
                    onsubmit='return imageClickHandler(this);' 
                    class='imageuploadform' >" +
                    "Image File: <input name='fileImage' type='file' 
                    class='fileImage' /></label><br/><br/><label class='imagelbl'>" +
                    "<input type='submit' name='submitImageBtn' 
                    class='sbtnimage' value='Upload' /></label></form>");
    $image.append($fileImage);
    $tr.append($image);  

        var $video = $("<td class='video'></td>"); 
var $fileVideo = $("<form action='videoupload.php' method='post' 
                enctype='multipart/form-data' target='upload_target_video'
                onsubmit='return videoClickHandler(this);' 
                class='videouploadform' >" +
                "Video File: <input name='fileVideo' type='file' 
                class='fileVideo' /></label><br/><br/><label class='videolbl'>" +
                "<input type='submit' name='submitVideoBtn' 
                class='sbtnvideo' value='Upload' /></label></form>");
$video.append($fileVideo);
$tr.append($video);  


        var $audio = $("<td class='audio'></td>"); 
var $fileAudio = $("<form action='audioupload.php' method='post' 
                enctype='multipart/form-data' target='upload_target_audio'
                onsubmit='return audioClickHandler(this);' 
                class='audiouploadform' >" +
                "Audio File: <input name='fileAudio' type='file' 
                class='fileAudio' /></label><br/><br/><label class='audiolbl'>" +
                "<input type='submit' name='submitAudioBtn' 
                class='sbtnaudio' value='Upload' /></label></form>");
$audio.append($fileAudio);
$tr.append($audio);  

}
   <form id="QandA" action="<?php echo htmlentities($action); ?>" method="post">

//image, video and audio upload form is appended into table below:

<table id="qandatbl" align="center" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
    <th class="image">Image</th>
    <th class="video">Video</th>
    <th class="audio">Audio</th>
</tr>
</thead>
</table>
<div id="qandatbl_onthefly_container">
<table id="qandatbl_onthefly" align="center" cellpadding="0" cellspacing="0" border="0">
<tbody>
</tbody>
</table>

    <p><input id="submitBtn" name="submitDetails" type="submit" value="Submit Details" /></p>

    </form>
<script type="text/javascript">                 
   $(function() {

    $('#submitBtn').click(myClickHandler(e)) 
});

      function myClickHandler(e){
        if (!validation())
            return false;    
        if (!confirm("Are you sure you want to Proceed?" + "\n" ))
            return false;    
        return true;
    }; 

</script>