How to use unbind() Method Event in JQuery

This article describe about unbind() Method Event in jQuery.
  • 2876

unbind() Method Event in jQuery

For remove event handlers from selected elements use the unbind() method.

It's remove all or selected event handlers, or stop specified functions from running  when event occurs.

Any event handler attached with jQuery unbind() method work on.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("p").click(function () {

            $(this).slideToggle();

        });

        $("button").click(function () {

            $("p").unbind();

        });

    });

</script>

</head>

<body>

<p>This is my first paragraph.</p>

<p>This is second  paragraph.</p>

<p>Click any p element to make it disappear. Including this one also.</p>

<button>Remove event handlers for p elements</button>

</body>

</html>

 

Output


unbind method pic5.jpg

 

Unbind Event Handlers and Functions from Elements
It is define one or more event handler to remove from selected element.
The unbind() method remove all event handler for selected element if no parameter define.
 

Syntax

 

$(selector).unbind(event,function)


Unbind Event Handlers Using an Event Object

 

It is define an event object to remove. Within itself it unbind an event.

The unbind() method remove all event handler for selected element if no parameter define.

 

Syntax

 

$(selector).unbind(eventObj)


You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.