DOM elements have an innerHTML
property
that allows you to read the HTML code of those
elements. Let's look at an example. Let's say
we have the following tag:
<p id="elem"><b>text</b></p>
Get a reference to this tag into a variable:
let elem = document.querySelector('#elem');
Read the HTML code of the tag:
console.log(elem.innerHTML); // shows <b>text</b>
Change the tag text:
elem.innerHTML = '<i>!!!</i>';
Given a paragraph and a button. On button click, read the HTML code of the paragraph and output it to the console.
Given a paragraph and a button. By clicking on the button, enter new text into the paragraph so that it is bold.