Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed jQuery Basics!
You have completed jQuery Basics!
Preview
Prevent the browser from following links on click with the preventDefault() method.
Further Reading
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
To be permitted to download a copy of
the jQuery Cheatsheet from our website,
0:00
the user first has to check the box
confirming that they want to Allow PDF
0:01
downloads.
0:05
If the box isn't checked and
they attempt to download it,
0:07
we'll display a message advising them that
they should check the box to confirm.
0:10
Right now our default behavior
is to download the PDF on click.
0:15
How can we conditionally
prevent this behavior?
0:20
To prevent an event from triggering
the browser's default behavior,
0:22
you call the preventDefault method.
0:26
Go ahead and open the workspace with
this video, and let's get to it.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up