Friday, December 27, 2024
Google search engine
HomeLanguagesJavascriptjQuery event.result Property

jQuery event.result Property

The jQuery event.result is an inbuilt property which is used to find the last and previous value returned by an event handler started by the specified event. 

Syntax:

event.result

Parameter: It does not accept any parameter because it is a property not a function. 

Example 1: jQuery code to show the working of event.result property.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
    <style>
        div {
            width: 40%;
            height: 100px;
            margin: 10px;
            padding: 10px;
            display: block;
            border: 2px solid green;
        }
    </style>
</head>
  
<body>
    <div>
        <!-- click on this button -->
        <button>Click here for event result</button>
        <p></p>
    </div>
    <!-- jQuery code to show working of this property -->
    <script>
        $("button").click(function (event) {
            return "Geeks for Geeks !";
        });
        $("button").click(function (event) {
            $("p").html(event.result);
        });
    </script>
</body>
  
</html>


Output:

 

Example 2: In this example, a pop-up will show last value returned by an event handler.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <script src=
    </script>
</head>
  
<body>
    <center>
        <div>
            <!-- click on this button -->
            <button>Click here for event result</button>
        </div>
        <!-- jQuery code to show working of this property -->
        <script>
            $("button").click(function (event) {
                return "Geeks for Geeks !";
            });
            $("button").click(function (event) {
                alert(event.result);
            });
        </script>
    </center>
</body>
  
</html>


Output:

 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments