开发者

convert this line of code into jQuery

following html coding are for the file uploading. I have a function which i want to write in jQuery style.

<form method="post" action="upload">

  <input type="file" id ="file_upload_id"/>
  <input type="submit" id= "dont_click" />

  <input type ="button"  id ="only_click_me" onClick="clickme();"/>
</form>

<script type="text/javascript">
    function clickme(){
       document.getElementID("file_upload_id").click(); // 

       document.getElementbyID("file_upload_id").onChange =  function() {
                     document.getElementById('dont_click').click()
                 };
    }
</script>

This is how i want to convert the lines of coding :

 $(function(){
    $("#file_upload_id").click(function() {
           on开发者_如何转开发Change : function(){
                         $("#dont_click").click();
                    }
     });
 });


This isn't really a question. More like: just do work for me. :-P

Anyway:

$("#file_upload_id").click();
$("#file_upload_id").change(function(){ $('#dont_click').click(); });


Like that,

$('#file_upload_id').trigger('click');
$('#file_upload_id').change(function () {
  $('#dont_click').trigger('click');
});


$(function() {
    $('#only_click_me').click(function() {
        $('#file_upload_id').click();
    });

    $('#file_upload_id').change(function() {
        $('#dont_click').click();
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜