Auto-click button element on page load using jQuery

JStormThaKid picture JStormThaKid · Sep 6, 2013 · Viewed 224.1k times · Source

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!

Answer

JStormThaKid picture JStormThaKid · Sep 6, 2013

You would simply use jQuery like so...

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

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