![jQuery Tutorial](/jquery/images/jquery-mini-logo.jpg)
- jQuery Tutorial
- jQuery - Home
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery DOM Manipulation
- jQuery - DOM
- jQuery - Add Elements
- jQuery - Remove Elements
- jQuery - Replace Elements
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
- jQuery Useful Resources
- jQuery - Questions and Answers
- jQuery - Quick Guide
- jQuery - Useful Resources
- jQuery - Discussion
jQuery event.result Property
The jQuery event.result property is used to retrieve the last or previous value returned by an event handler triggered by the specified event.
This property contains the value that was returned by the previous event handler for the same event. If the previous handler did not return any value, the event.result will be undefined.
Syntax
Following is the syntax of the jQuery event.result property −
event.result
Parameters
This property does not accept any parameter.
Return Value
This property returns the last or previous value returned by an event handler.
Example 1
The following is the basic example of the jQuery event.result property −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> </head> <body> <p>Click on the below button to see the event result</p> <button>Click me!</button> <script> $('button').click(function(){ return "TutorialsPoint"; }); $('button').click(function(event){ alert("Eevnt result: " + event.result); }) </script> </body> </html>
Output
The above program displays a button, and when the button is clicked, a pop-up alert appears displaying the event result on the browser screen −
When the button is clicked −
Example 2
The following is another example of the jQuery event.result property. We use this property to retrieve the return value of the event handler that was triggered by the specified element −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> <style> button{ background-color: green; color: white; padding: 10px } span{ color: green; font-weight: bold; } </style> </head> <body> <p>Click on the below button to see the event result</p> <button>Click to see event result</button> <span></span> <script> $('button').click(function(){ return "Welcome to TP"; }); $('button').click(function(event){ $('span').text("Eevnt result: " + event.result); }) </script> </body> </html>
Output
After executing the above program, it displays a button, when it is clicked the event result will be displayed next to it −
When the button is clicked −
Example 3
If the previous event handler does not return any value, the event.result will be undefined −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> </head> <body> <p>Click on the below button to see the event result</p> <button>Click</button> <span></span> <script> $('button').click(function(){ return; }); $('button').click(function(event){ $('span').text("Eevnt result: " + event.result); }) </script> </body> </html>
Output
The above program returns undefined as a result −