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 blur() Method
Next article icon

jQuery bind() Method

Last Updated : 22 Apr, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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);

Parameters

It accepts three parameters that are described below:

  • event: This is an event type that is passed to the selected elements.
  • data: This is the data that can be shown over the selected elements.
  • function: This is the function that is performed by the selected elements.

Note: This method has been deprecated.

Example 1: In this example, “click” events are attached to the given paragraph using bind() method. 

HTML
<!DOCTYPE html> <html>  <head>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>      <script>         $(document).ready(function () {             $(".paragraph").bind("click", function () {                 alert("Paragraph is Clicked");             });         });     </script>      <style>         .paragraph {             width: 190px;             margin: auto;             padding: 20px 40px;             border: 1px solid black;         }     </style> </head>  <body>     <p class="paragraph">Welcome to GeeksforGeeks</p> </body>  </html> 

Output: 

jQuery-bind-method

Example 2: In this example, the “click” event is added but this time data is also passed to the bind() method. 

HTML
<!DOCTYPE html> <html>  <head>     <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">     </script>      <script>         function handlerName(e) {             alert(e.data.msg);         }          $(document).ready(function () {             $(".paragraph").bind("click", {                 msg: "Paragraph is Clicked."             }, handlerName)         });     </script>      <style>         .paragraph {             width: 190px;             margin: auto;             padding: 20px 40px;             border: 1px solid black;         }     </style> </head>  <body>     <p class="paragraph">Welcome to GeeksforGeeks</p> </body>  </html> 

Output:

jQuery-bind-method



Next Article
jQuery blur() Method

K

kundankumarjha
Improve
Article Tags :
  • JQuery
  • Web Technologies
  • jQuery-Methods

Similar Reads

  • 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 blur() Method
    jQuery blur() is an inbuilt method that is used to remove focus from the selected element. This method starts the blur event or it can be attached a function to run when a blur event occurs.  Syntax:$(selector).blur(function)Parameters: It accepts an optional parameter "function".  jQuery examples t
    1 min read
  • jQuery change() Method
    The jQuery change() method is used to detect changes in the value of form elements like <input>, <select>, or <textarea>. It triggers a specified function when a user modifies the input or selects a different option. Syntax$(selector).change(function)Parameters : It accepts an opti
    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 dblclick() Method
    jQuery dblclick() is an inbuilt method that is used to trigger the double-click event to occur. This method occurs when the selected element will be double-clicked.  Syntax:$(selector).dblclick(args);Here "selector" is the selected element.  Parameters: It accepts an optional parameter "args" which
    2 min read
  • jQuery event.isDefaultPrevented() Method
    jQuery isDefaultPrevented() Method is an inbuilt method that checks whether the preventDefault() method was called for the event. This method returns a boolean value. It returns True if preventDefault() is called on the event, False otherwise.  Syntax:event.isDefaultPrevented()Parameters: It accepts
    2 min read
  • jQuery event.isImmediatePropagationStopped() Method
    jQuery isImmediatePropagationStopped() Method is used to check whether this method was called for the event or not. If it was called then it will be "true" or else "false".  Syntax:$(selector).isImmediatePropagationStopped()Parameters: This method accepts only one parameter as a selector which is us
    2 min read
  • jQuery event.isPropagationStopped() Method
    jQuery event.isPropagationStopped() Method is used to check whether the object event.stopPropagation() is called or not. If event.stopPropagation() is called then it returns true otherwise returns false.  Syntax:event.isPropagationStopped()Parameters: It contains a single parameter event which is ma
    1 min read
  • jQuery event.preventDefault() Method
    The jQuery preventDefault() Method is used to stop the default action of the selected element to occur. It is also used to check whether preventDefault() method is called for the selected element or not. Syntax: event.preventDefault()Parameter: It does not accept any parameter. Example 1: This examp
    2 min read
  • jQuery event.stopImmediatePropagation() Method
    The jQuery event.stopImmediatePropagation() is an inbuilt method in jQuery used to stop the rest of the event handlers from being executed for the selected element. Syntax: event.stopImmediatePropagation() Parameter: No parameter is required. Example 1: Here, only first pop box will appear after thi
    2 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