jQuery or JavaScript auto click

后端 未结 6 481
情书的邮戳
情书的邮戳 2020-12-23 21:50

How can I auto click on the link on page load? I have been trying for ages but id does not work.



        
6条回答
  •  渐次进展
    2020-12-23 22:32

    First i tried with this sample code:

    $(document).ready(function(){ 
         $('#upload-file').click(); 
    });
    

    It didn't work for me. Then after, tried with this

    $(document).ready(function(){ 
         $('#upload-file')[0].click(); 
    });
    

    No change. At last, tried with this

    $(document).ready(function(){ 
         $('#upload-file')[0].click(function(){
         }); 
    });
    

    Solved my problem. Helpful for anyone.

提交回复
热议问题