jQuery Event How to - Bind more than one event actions








Question

We would like to know how to bind more than one event actions.

Answer


<!--  w  ww  . ja  v  a 2  s .  co m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
             $("h1").bind("mouseenter mouseleave", function(e){
                 var str = "( " + e.pageX + ", " + e.pageY + " )";
                 $("h1").text("Click happened! " + str);
             });
        });
    </script>
  </head>
  <body>
       <div><h1>header 1</h1></div>
  </body>
</html>

The code above is rendered as follows: