jQuery > Events

Mouse down event in jQuery

How to attach mouse down event to a html element in jQuery?


To attach mouse down event to a html element, mousedown() method can be used.

<div id="spanMouseDownUp" style="background:green;color:White;padding:10px;">Try to click here</div>

    <script>
        $("#spanMouseDownUp").mousedown(function () {
            $(this).html("Mouse down");
        });
    </script>

In the above code when user start clicking mouse on the “spanMouserDownUp” element “Mouser clicked” is written inside it.

 Views: 5084 | Post Order: 77



Write for us






Hosting Recommendations