Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • difference between event.preventDefault() and return false in Javascript?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 119
    Comment on it

    In javascript , e.preventDefault() will always prevent the event from occurring which is default event.

    It simply means that If any method is called, then the default action of that particular event will not be triggered.

    Note: - We can't pass the parameter along with this javascript method.

    Example:

    jQuery(document).ready(function(){
        $('a.link').click(function (e) {
            e.preventDefault();
        });
    });
    

    e.stopPropagation() in javascript always prevent the event from bubbling.

    It simply means that If any method is called, then this method prevents that event from bubbling up over the DOM(Document object modal) tree.

    Note: - We can't pass the parameter along with this javascript method as well.

    Example:

    jQuery(document).ready(function(){
        $('a.link').click(function (e) {
            e.stopPropagation();
        });
    });
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: