JavaScript ondblclick event

 The JavaScript ondblclick event is one of the JavaScript event events. Its function is similar to the onclick event. The biggest difference is that ondblclick must be triggered when the user double-clicks a web page element. Clicking will have no effect. It feels like it is in the operating system. On the top, click a folder to select the folder, double-click the folder to open it, the same effect can be moved to the web page, you can use ondblclick to create, all mainstream browsers support the ondblclick event effect.


JavaScript ondblclick event syntax

ondblclick = "javascript function to be executed"


The main function of the ondblclick event is the same as other JavaScript events . It is used to monitor the user's behavior. When the user double-clicks a specific element, it immediately triggers the function that is prepared to be executed, and then the function starts to work. And ondblclick succeeded.

JavaScript ondblclick event example
<script language="javascript">
function ShowName(){
    alert('Your name is:'+document.getElementById("MyName").value);
}
</script>
Please enter your name: <input type="text" id="MyName">
<input type="button" value="Double click to get the name just entered" ondblclick='ShowName()'>
Example output
Please enter your name: 
Suppose you fill in a name at random, double-clicking the button of the example will trigger the ShowName function, get the name just filled in through the document.getElementById method of the DOM , and pop out the dialog window to tell us what you filled in. This is just a simple example , The ondblclick event is inserted in the button ( button ) to illustrate. In fact, the ondblclick event can be placed not only on form elements, but also on other elements in the web page, such as DIV blocks, span areas, img tags, etc., application The range is very wide.

Post a Comment

0 Comments