Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is the different between onclick and click

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 881
    Comment on it

    on('click', function() use less memory then .click(function() and it works on dynamically added elements.If we are using on('click', function() then we can remove this handler by using off('click', function(). The main advantage of on click is that it works on dynamically added elements. .click is the shortcut method for on click. If we are not using dynamically element then these works same for bind a handler to the click

    $("divid").click(function() {
        alert("Hi");
    });
    
    
    $("divid").on('click',function() {
        alert("Hi");
    });
    

 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: