user13267
user13267

Reputation: 111

Selecting a div with an ID and automatically clicking on it on page load with JQuery

I have a div on my page with the ID of #activateeditbutton. I want this div to be automatically clicked when the page loads.

Here is the code I have written in jQuery, but it does not seem to work. If someone can point out my mistake I would greatly appreciate it. Thanks.

<script type="text/javascript">

jQuery(document).ready(function(){
  $('#activateeditbutton').simulate('click');
});

</script>

Upvotes: 1

Views: 362

Answers (2)

Satpal
Satpal

Reputation: 133403

You need to use .trigger()

 $('#activateeditbutton').trigger('click');

Upvotes: 1

Subash Selvaraj
Subash Selvaraj

Reputation: 3385

Try this,

jQuery(document).ready(function(){
      $('#activateeditbutton').trigger('click');
    });

Upvotes: 5

Related Questions