1

Maybe it's a dumb question but I'd like to know the difference. When I want to invoke action when clicking on a button I have two options:

first one is callback:

$("button").click(function(){
    $("p").hide("slow", function(){
        alert("The paragraph is now hidden");
    });
});

The second one is using HTML onclickevent attribute:

<button onclick="myFunction()">Click me</button>

The second one looks like more reliable. When you're looking at the code you can understand much more easy what is going on here, etc, etc...

But I'm wondering is there any drawback in such approach? Can I replace all callbacks with second approach?

Anatoly
  • 4,553
  • 6
  • 42
  • 110

0 Answers0