0

Can somebody tell me how to auto click the button in a page when it loads? I've tried this code in javascript but it doesn't `work.

<a href="javascript:Clickheretoprint()" id="print">

<script type="text/javascript">
$(document).ready(function(){
    $("#print").click(); 
});
</script>

is there any way to do this??

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81

1 Answers1

0

Please try following :

$("#print")[0].click();

The answer is from the following link :

Using jQuery to programmatically click an <a> link

Community
  • 1
  • 1
Rumel
  • 319
  • 1
  • 3
  • 19
  • As this answer ( http://stackoverflow.com/a/23904765/1675954) will doubtfully be deleted (as it has 61 votes), you would have been better to submit this as a duplicate question – Rachel Gallen Jan 28 '17 at 15:01
  • @RachelGallen I agree with you. I will delete my answer and try to mark it as duplicate. – Rumel Jan 28 '17 at 15:20