Exercise 10.8
This is Exercise 10.8, lecture on modifying DOM with Javascript, used in the course IDATA2301 Web technologies at NTNU, campus Aalesund.
Purpose
The purpose of the exercise is to learn how you can access and modify element classes in Javascript.
Instructions
- Create a page with one paragraph of text.
-
Add a CSS block which sets a yellow background and font to
Courier New
for all items with classyellow
. - Add two buttons A and B to the page.
-
Button A should have a text "Add". When user clicks on it, class
yellow
is added to the text paragraph (and hence it should get a yellow background). -
Button B should have a text "Remove". A click on it removes the
yellow
class from the paragraph.
Solution
You can find a solution in here.