From fe84fbd4ce8c5c8d867978ffc4eede0c3132df27 Mon Sep 17 00:00:00 2001 From: Marie Malarme Date: Mon, 8 Mar 2021 12:01:29 +0000 Subject: [PATCH] bring-it-to-life: add code examples to get an element by id in js and set its style properties --- subjects/bring-it-to-life/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subjects/bring-it-to-life/README.md b/subjects/bring-it-to-life/README.md index ad22f98c..4fddd86e 100644 --- a/subjects/bring-it-to-life/README.md +++ b/subjects/bring-it-to-life/README.md @@ -19,6 +19,15 @@ In the JS file, add the freshly-created class `eye-closed` to the [`classList`]( Reload the page - it's alive! Your JS brain has control and orders your HTML/CSS body to close one eye. +### Code examples + +Get a HTML element by its `id` & set its inline style: + +```js +const myDiv = document.getElementById('my-div') +myDiv.style.color = 'green' +``` + ### Expected output This is what you should see in the browser: