Let’s look at sample html.
When you click on
Java then you will get two alerts. That is because the click on element p will propagate outward and it will be caught by element div which has onclick trigger.
If you do not want the event to propagate then here is a way to stop it.
Stopping the default behavior
Converting a regular html link into an AJAX request is easy. One of the things you need to do is to
return false so that the click operation does not perform its default behavior.
However there is another way to handle such cases.
preventDefault stops the default behavior. The same code could be written as