A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/HTMLElement/click below:

click ยท WebPlatform Docs

click Summary

Covers what the click action is and what happens when it is performed.

Method of dom/HTMLElementdom/HTMLElement

Syntax
var object = object.click();
Return Value

Returns an object of type DOM NodeDOM Node

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

The following example demonstrates how simulating a click using the click does not, by default, bring the element into focus.

<!DOCTYPE html>
<html>
<head>
<title>onfocus Sample</title>
<link rel="stylesheet" type="text/css" href="samplesSDKIE4.css" />
</head>
<body>
  <p>DEMO: USING CLICK METHOD DOES NOT SET FOCUS<p>
    <ul>
      <li>Both these buttons apply the click method to the check box. </li>
      <li>An alert has been set to fire when the check box is put into focus.</li>
    </ul>
  </p>
  <input type="checkbox" id="chk1"/>
    <br>
    <button onclick="simclick1()">This button <strong>applies the focus method</strong> to
      check box</button>
    <br>
    <button onclick="simclick2()">This button <strong>does not apply the focus method</strong> to check box</button>
    <br>

  <script>
    
    document.getElementById("chk1").addEventListener("focus", function(){alert("check box is in focus!");}, false);
    function simclick1() {
      chk1.focus(); 
      chk1.click();
    }
    function simclick2() {
      chk1.click();
    }
  </script>
</body>
</html>

View live example

Notes Remarks

Note Simulating a click using the click does not bring the element being clicked into focus. (See example below).

Syntax Standards information Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4