DOM Manipulation

Default Actions

Default Actions

Some events come with browser behaviour. Clicking a link normally navigates. Submitting a form normally sends a request or reloads the page.

preventDefault tells the browser that your JavaScript is handling the interaction. The event still happened, but the built-in action should not continue.

Your task: When the preview link is clicked, prevent its default navigation and update the notice text to say that the preview opened inline.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Default Actions

Some events come with browser behaviour. Clicking a link normally navigates. Submitting a form normally sends a request or reloads the page.

preventDefault tells the browser that your JavaScript is handling the interaction. The event still happened, but the built-in action should not continue.

Your task: When the preview link is clicked, prevent its default navigation and update the notice text to say that the preview opened inline.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.