.mouseup()

In this chapter you will learn:

  1. Syntax and Description for .mouseup() event
  2. How to listen to mouse up event

Syntax and Description

.mouseup(handler)            
.mouseup()

handler is a function to execute each time the event is triggered. Return value is the jQuery object, for chaining purposes.

mouseup binds an event handler to the mouseup JavaScript event, or trigger that event on an element.

.mouseup(handler) is a shortcut for .bind('mouseup', handler), .mouseup() is a shortcut for .trigger('mouseup').

Listen to mouse up event

The following code adds handler for mouse up event.

<html><!--  j  a va2  s  .c om-->
  <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 2s .com</div>
    </body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to use .off() to remove event handler
Home » jQuery » Event
Event
Event attributes
event.keycode
event.clientX/clientY
pageX/pageY
Cancel event
Event target
bind
.blur()
.change()
.click()
.error()
.dblclick()
.delegate()
.die()
.focus()
.hover()
.keydown()
.keypress()
.keyup()
.live()
.load()
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseover()
.mouseout()
.mouseup()
.off()
.on()
.one()
.ready()
.resize()
.scroll()
.select()
.submit()
.toggle()
.trigger()
.triggerHandler()
.unbind()
.undelegate()
.unload()