X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM click() Method

HTMLElement Object Reference Element Object

Definition and Usage

The click() method simulates a mouse-click on an element.

Syntax

HTMLElementObject.click()


Example

Example

Simulate a mouse-click on a button on body onload:

<html>
<head>
<script>
function clickButton()
  {
  document.getElementById('button1').click()
  }
function alertMsg()
  {
  alert("Button 1 was clicked!")
  }
</script>
</head>
<body onload="clickButton()">

<form>
<input type="button" id="button1" onclick="alertMsg()"
value="Button 1">
</form>

</body>
</html>

Try it yourself »


HTMLElement Object Reference Element Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook