Posted in jquery
167
3:41 am, August 23, 2021

simulate a click on an element with jquery

you can actually use jquery to simulate a click event using the following

.click()

so as soon as the document is ready and you have jquery loaded it will run the click event for you, and should pop up that alert

unless alerts have been depreciated in your browser, which they are going to be soon apparently. 

simulate a click on an element with jquery Demo

View Demo Full Screen View Demo New Tab

simulate a click on an element with jquery Code

HTML

<button class='btn btn-primary' id='click-me' onclick="alert('test');">Click Me (or dont...)</button>

Javascript

$(document).ready(function(){
	$("#click-me").click();
});

Related Tags

No Items Found.

Add Comment
Type in a Nick Name here
 
Related Search Terms