Skip to content

Instantly share code, notes, and snippets.

@ihollander
Last active October 20, 2020 20:54
Show Gist options
  • Save ihollander/49d9a46e260ac3a81fce68bd9e32a338 to your computer and use it in GitHub Desktop.
Save ihollander/49d9a46e260ac3a81fce68bd9e32a338 to your computer and use it in GitHub Desktop.
p tag challenge

<p> tag challenge

Write code that handles the following action:

  • When a user clicks on any <p> tag on a webpage, change the font of the <p> tag that was clicked to comic sans.

You should be able to test your code by opening up a console on any webpage that has <p> tags (so, pretty much any webpage... NY Times, Wikipedia, and Medium are fun) and pasting in your solution.

If you want some hints, expand the sections below.

Click to show Hint #1

HINT: You might need to loop over all the <p> tags somehow, or use event delegation...

Click to show Hint #2

HINT: If wondering how to loop over all the <p> tags, querySelectorAll is a nice way to access a collection of elements...

Click to show Hint #3

HINT: If you're not sure how to set an element's font to Comic Sans, here's one way to do it:

element.style.fontFamily = '"Comic Sans MS", cursive, sans-serif'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment