<div id="divuploadpic">
    <form name="uploader" method="post" action="upload.php" enctype="multipart/form-data">
         <input type="file" name="uploadedpic" id="uploadedpic" style="display: none;" />
         <input type="submit" name="submituploadedpic" id="submituploadedpic" />
    </form>
</div>
<script>
$(function(){
    $("#divuploadpic").click(function(){
        $("#uploadedpic:hidden").trigger('click');
     });
});
</script>


我已经隐藏了输入文件标签和onclicking div,应该是triggered.$("#divuploadpic").click(function()正常工作,但触发器在这里不起作用。怎么解决呢?

最佳答案

对于我的建议:

更好地用于label标签而不是div无需js即可执行



<label id="divuploadpic" for="uploadedpic">click
  <form name="uploader" method="post" action="upload.php" enctype="multipart/form-data">
    <input type="file" name="uploadedpic" id="uploadedpic"  style="display:none"/>
    <input type="submit" name="submituploadedpic" id="submituploadedpic" />
  </form>
</label>

09-19 10:29