How to Auto Click in HTML Button

<h1>Welcome to My Page!</h1>
<h2>My name is Bob.</h2>
<h3>I hope you like it here.</h3>
<embed src="MY WEBSITE LINK">
<input type="checkbox" onmouseover="myFunction()" onclick="alert('clicked')">
<script>
jQuery(function(){ jQuery('#btd').click();
});
</script>

I have the code. But didn't Work.

How to Auto Click Button Continue, from Image?

2

1 Answer

We can't do auto click in HTML, but we can call any function that the button does with Jquery. To work Jquery code, you want to add this to your code

<script src=""></script>

Actually when we click any button, it calls a function, that may be our own function or built in one. Here Javascript can easily call any function without any buttonLike this

//define the function
function alertsomething(){ alert("Hey, This is an alert inside that function");
}
//function works when button clicks
$("#btd").click(function(){ alertsomething();
})
//function automatically when page loads
$(document).ready(function(){ alertsomething();
})
<script src=""></script>
<button >Click me</button>

Here are the two ways to call a function. One is when you click the button and another one is when your page loads, that function will call automatically...

Thanks

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like