Add click and hover in same function - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Add click and hover in same function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
      <script type="text/javascript">
    $(function(){/*from   ww w .j a  v  a 2  s. c  o  m*/
$('.img').hover(function (event) {
    console.log(event)
}).on("click", function (event) {
    console.log(event)
});
    });

      </script> 
   </head> 
   <body> 
      <span class="img">span</span>  
   </body>
</html>

Related Tutorials