Return the value of the previous click event:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from w ww. j av a 2 s. co m*/ <script> $(document).ready(function(){ $("button").click(function(){ return "Hello world!"; }); $("button").click(function(event){ $("p").html(event.result); }); }); </script> </head> <body> <button>Click me to display event.result</button> <p>This is a paragraph.</p> </body> </html>
The event.result property returns the last/previous value returned by an event handler triggered.
event.result
Parameter | Optional | Description |
---|---|---|
event | Required. | The event parameter comes from the event binding function |