.mousedown()
In this chapter you will learn:
Syntax and Description
.mousedown()
.mousedown(handler)
handler
is a function to execute each time the event is triggered.
Return value is the jQuery object, for chaining purposes.
.mousedown binds an event handler to the mousedown JavaScript event, or trigger that event on an element.
.mousedown(handler)
is a shortcut for
.bind('mousedown', handler)
.
.mousedown()
is a shortcut for .trigger('mousedown')
.
Listen to mouse down event
The following code listen to mouse down event.
<html><!-- jav a2 s . c o m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").mouseup(function(){
$(this).append('<span style="color:#F00;">Mouse up.</span>');
}).mousedown(function(){
$(this).append('<span style="color:#00F;">Mouse down.</span>');
});
});
</script>
</head>
<body>
<body>
<div>java 2 s .com</div>
</body>
</html>
Next chapter...
What you will learn in the next chapter: