Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-click button element on page load using jQuery

Tags:

If I wanted to auto-click a button element on page load, how would I go about this using jQuery?

The button html is

<button class="md-trigger" id="modal" data-modal="modal"></button> 

Any help on this topic would be greatly appreciated! Thanks in advance!

like image 230
JStormThaKid Avatar asked Sep 05 '13 22:09

JStormThaKid


People also ask

How to click button automatically using jQuery?

The click() is an inbuilt method in jQuery that starts the click event or attach a function to run when a click event occurs. Syntax: $(selector). click(function);

How to trigger click event in jQuery after page load?

$("document"). ready(function() { $("ul. galleria li:first-child img"). trigger('click'); });

How to trigger click event in jQuery on document ready?

$(document). ready(function() { $('#titleee'). find('a'). trigger('click'); });


1 Answers

You would simply use jQuery like so...

<script> jQuery(function(){    jQuery('#modal').click(); }); </script> 

Use the click function to auto-click the #modal button

like image 191
JStormThaKid Avatar answered Sep 18 '22 11:09

JStormThaKid