Calling the preventDefault()
method of the event object will cancel the default handling that the browser is programmed to execute.
Opening a new page on an a
element click
event, for example.
Or submitting a form
on the submit
event.
Calling preventDefault()
is what you need to do to completely customize the action. Perhaps by creating a fetch
request to load some JSON instead of opening a new page on a link click.
Other event handlers defined on this same element will execute. Unless you call event.stopImmediatePropagation()
.
Lessons in this unit:
Are you intimidated by Git? Can’t figure out
merge vs rebase? Are you afraid of screwing up
something any time you have to do something in
Git? Do you rely on ChatGPT or random people’s
answer on StackOverflow to fix your problems?
Your coworkers are tired of explaining Git to
you all the time? Git is something we all need
to use, but few of us really master it. I
created this course to improve your Git (and
GitHub) knowledge at a radical level. Launching
May 21, 2024. Join the waiting list!