Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

How to stop default hashtag behavior with jQuery ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The event.isDefaultPrevented() method in jQuery is used to determine if this method has been called by an event handler that was triggered by this event. If event.preventDefault() method is called, and the default action of the event will not be triggered.

Syntax:

event.preventDefault()

Parameters: This method does not accept any parameter.

Return Value: This method returns undefined.

Example: In this example, we are using event.isDefaultPrevented() method in jQuery.

HTML




<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    </script>
</head>
 
<body>
    <a href="https://jquery.com">
        default click action is prevented
    </a>
    <div id="log"></div>
    <script>
        $("a").click(function (event) {
            event.preventDefault();
            $("<div>")
                .append("default "
                    + event.type + " prevented")
                .appendTo("#log");
        });
    </script>
</body>
</html>

Output:

My Personal Notes arrow_drop_up
Last Updated : 05 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials