Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • jQuery Tutorial
  • jQuery Selectors
  • jQuery Events
  • jQuery Effects
  • jQuery Traversing
  • jQuery HTML & CSS
  • jQuery AJAX
  • jQuery Properties
  • jQuery Examples
  • jQuery Interview Questions
  • jQuery Plugins
  • jQuery Cheat Sheet
  • jQuery UI
  • jQuery Mobile
  • jQWidgets
  • Easy UI
  • Web Technology
Open In App
Next Article:
jQuery | unload() Method
Next article icon

jQuery | unbind() Method

Last Updated : 20 Feb, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The unbind() Method is an inbuilt method in jQuery which is used to remove any selected event handlers. This method can be used to remove particular event handler, or stop specific functions. It works on any event handler using an event object.

Note: If no parameters are provided, the method works on all event handlers from the specified element.
Syntax:

$(selector).unbind(event, function, eventObj)

Parameters: This method accepts three parameters as mentioned above and described below:

  • event: It is an optional parameter which is used to specify events (one or more) to remove them from the elements.
  • function: It is an optional parameter which is used to specify the name of the function to unbind from the specified event for the element.
  • eventObj: It is an optional parameter which is used to specify the event object to remove from the event binding function.

Example 1: This example describes the unbind() method to remove event handler from selected element.




<!DOCTYPE html>  
<html>  
  
<head> 
    <title> 
        jQuery unbind() Method
    </title> 
      
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
 </head> 
         
 <body style = "text-align:center;">  
     
    <h1 style = "color:green;" >  
        GeeksForGeeks  
    </h1>  
             
    <button> 
        Click Here 
    </button> 
          
    <!-- Script to illustrates unbind() method -->
    <script>
        $(document).ready(function() {
            $("h1").click(function() {
                $(this).slideToggle();
            });
              
            $("button").click(function() {
                $("h1").unbind();
            });
        });
    </script>
</body>  
  
</html> 
 
 

Output:

  • Before click anywhere:
  • After clicking on the element h1:
  • After clicking on the button event will not work:

Example 2: This example describes the unbind() method to remove event handler from selected element.




<!DOCTYPE html>  
<html>  
  
<head> 
    <title> 
        jQuery unbind() Method
    </title> 
      
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
      
    <style>
        h1 {
            border: 1px solid black;
            height: 100px;
            padding-top: 35px;
            background: green;
            color: white;
        }
    </style>
</head> 
         
<body style = "text-align:center;">  
     
    <h1>GeeksForGeeks</h1>  
      
    <button> 
        Remove event handler from geeks for geeks
    </button> 
      
    <!-- Script to illustrates unbind() method -->   
    <script>
        $(document).ready(function() {
            $("h1").click(function() {
                $(this).slideToggle();
            });
              
            $("button").click(function() {
                $("h1").unbind();
            });
        });
    </script>
</body>  
  
</html> 
 
 

Output:

  • Before click anywhere:
  • After clicking on the element h1:
  • After clicking on the button event will not work:


Next Article
jQuery | unload() Method

A

ashishsaini3
Improve
Article Tags :
  • JQuery
  • Web Technologies
  • jQuery-Events

Similar Reads

  • jQuery | unload() Method
    The unload() method in jQuery is used to perform unload event when the user try navigates away from current webpage.The event can be triggered when user changes the dynamic state of the page for example user clicked on link to leave the page, a new URL is typed in the address bar etc. the unload met
    2 min read
  • jQuery unwrap() Method
    The unwrap() method is an inbuilt method in jQuery which is used to remove the parent element from the selected element. Syntax: $(selector).unwrap()Parameters: This method does not accept any parameter. Return Value: This method returns the selected element with the changes made by unwrap() method.
    1 min read
  • jQuery undelegate() Method
    The jQuery undelegate() method is an inbuilt method that is used to remove the specified event handler from the selected element. Syntax: $(selector).undelegate(selector, event, function)Parameters: This method accepts three parameters as mentioned above and described below: selector: It is an optio
    2 min read
  • jQuery | off() Method
    The off() Method in jQuery is used to remove event handlers attached with the on() method. The off() method brings a lot of consistency to the API and it replace unbind(), die() and undelegate() methods. Syntax: $(selector).off(event, selector, function(eventObj), map) Parameter: This method accepts
    2 min read
  • jQuery remove() Method
    The remove() method in JQuery is used to remove all the selected elements including all the text. This method also remove data and all the events of the selected elements. Syntax: $(selector).remove()Return Value: It will return all the data of the selected elements deleted. Example 1: Input: $("p")
    2 min read
  • jQuery pushStack() Method
    The pushStack() method in jQuery is used to add a collection of DOM elements onto the jQuery stack. Syntax: .pushStack(elements, name, arguments)Parameters: elements: This is the array of elements to be pushed onto the stack and make into a new jQuery object.name: This argument defines the name of a
    2 min read
  • jQuery bind() Method
    The jQuery bind() method is used to attach one or more event handlers for selected elements. This method specifies a function to run when an event occurs.  Syntax$(selector).bind(event, data, function);ParametersIt accepts three parameters that are described below: event: This is an event type that
    2 min read
  • jQuery click() Method
    jQuery click() is an inbuilt method that starts the click event or attaches a function to run when a click event occurs.  Syntax:$(selector).click(function);Parameters: It accepts an optional parameter "function" which is used to run when a click event occurs.  jQuery examples to show the working of
    2 min read
  • jQuery detach() Method
    The detach() is an inbuilt method in jQuery that removes the selected elements from the DOM tree including all text and child nodes but it keeps the data and the events. Document Object Model (DOM) is a World Wide Web Consortium standard. This defines accessing elements in the DOM tree. Syntax: $(se
    1 min read
  • jQuery UI Menu destroy() Method
    The jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. jQuery UI menu is a Themeable menu that is used with a mouse and keyboard interactions for navigating between pages. In this arti
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences