- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to pass a jQuery event as a parameter in a method?
To pass a jQuery event as a parameter in a method, use the bind() method.
Example
You can try to run the following code to learn how to apss a jQuery event as a parameter:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#btn1").bind("click", { key1: "value1", key2: "value2" }, myFunction); function myFunction (event) { $("#myid").text(event.data.key1); } }); </script> </head> <body> <input id= "btn1" type="button" value="click me" /> <div id = "myid" style="border:2px solid blue; width:400px; height:300px"> </body> </html>
- Related Articles
- How to pass a lambda expression as a method parameter in Java?
- How to pass a function as a parameter in Java
- How to pass a 2D array as a parameter in C?
- How to pass a json object as a parameter to a python function?
- How to pass an object as a parameter in JavaScript function?
- How to pass an array as a URL parameter in Laravel?
- How can I pass a parameter to a setTimeout() callback?
- Set tuple as a method parameter in C#
- C# Program to pass Parameter to a Thread
- Pass long parameter to an overloaded method in Java
- Java Program to pass lambda expression as a method argument
- How to disable a particular jQuery event on a page?
- Can I wrap a JavaScript event in a jQuery event?
- How to pass a variable into a jQuery attribute-contains selector?
- How do I pass an event handler to a component in ReactJS?

Advertisements