Home  >  Article  >  What event is mousedown

What event is mousedown

(*-*)浩
(*-*)浩Original
2019-06-22 11:21:5710115browse

mousedown

The mousedown event occurs when the mouse pointer moves over the element and the mouse button (either left or right button) is pressed.

Unlike the click event, the mousedown event only requires the key to be pressed and does not need to be released to occur.

What event is mousedown

mouseup(Recommended learning: JavaScript video tutorial)

When releasing the mouse button on an element (either left or right click), the mouseup event will occur.

Unlike the click event, the mouseup event only requires the button to be released. This event is fired when the mouse button is released when the mouse pointer is over the element.

click

A click event occurs when the mouse pointer stays over an element, and then the left mouse button is pressed and released.

Note: The condition for triggering the click event is to press and release the left mouse button! , pressing and releasing the right mouse button will not trigger the click event.

The triggering sequence of the three events

If you press and release the left mouse button on the same element, mousedown, mouseup, and click will be triggered in sequence. The previous one The next event will not be executed until the event is executed.

If you press and release the right mouse button on the same element, mousedown and mouseup will be triggered in sequence. The next event will not be executed until the previous event is executed. No Trigger click event

Example: When the mouse button is pressed, hide or show elements:

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").mousedown(function(){
$("p").slideToggle();
});
});
</script>
</head>
<body>
<p>这是一个段落。</p>
<button>切换</button>
</body>
</html>

For more js related technical articles, please visitjs tutorial column for learning!

The above is the detailed content of What event is mousedown. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn