Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Jquery Mouse Events

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 597
    Comment on it

    Event methods trigger or join a function to an event handler for the choosen elements. Mouse events attaches an event handler function to an HTML element. Here, below are some of the mouse events :-

    .click() :-  The function is executed when the user clicks on the HTML element.

    Example :- 

    <script>
    $(document).ready(function(){
        $("p").click(function(){
            $(this).hide();
        });
    });
    </script>
    </head>
    <body>
    
    <p>Click here to hide</p>
    <p>Click Here</p>
    <p>Click Here</p>
    

    .dblclick() :-  The function is executed when the user double-clicks on the HTML element.

    Example :-

    <script>
    $(document).ready(function(){
        $("p").dblclick(function(){
            $(this).hide();
        });
    });
    </script>
    </head>
    <body>
    
    <p>Double-click here to hide.</p>
    <p>Click Here </p>
    <p>Click Here </p>
    
    </body>

    .mousedown() :-  When the mouse is over the HTML element, the left, middle or right mouse button is pressed down to execute this function.

    Example :-

    <script>
    $(document).ready(function(){
        $("#p1").mousedown(function(){
            alert("Mouse down over p1!");
        });
    });
    </script>
    </head>
    <body>
    
    <p id="p1">This is a paragraph.</p>
    
    </body>

     .mouseup() :-  When the mouse is over the HTML element, the left, middle or right mouse button is released to execute this function.

    Example :-

    <script>
    $(document).ready(function(){
        $("#p1").mouseup(function(){
            alert("Mouse up over p1!");
        });
    });
    </script>
    </head>
    <body>
    
    <p id="p1">This is a paragraph.</p>
    
    </body>

     hover() :-  It attaches one or two handlers to the matched elements to  execute when two methods hovers the elements and this happens with the help of  following two methods :-

    • mouseenter() is executed when the mouse enters the HTML element.
    • mouseleave() is executed when the mouse leaves the HTML element.

    Example :-

    <script>
    $(document).ready(function(){
        $("#p1").hover(function(){
            alert("You entered!");
        },
        function(){
            alert("You leave");
        });
    });
    </script>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: