# Working with element text in JavaScript

DOM elements have a `textContent` property that allows you to read the text of those elements. Let's look at an example. Let's say we have the following tag:

`<p id="elem">text</p>`

Get a reference to this tag into a variable:

`let elem = document.querySelector('#elem');`

Read the tag text:

`console.log(elem.textContent);`

Change the tag text:

`elem.textContent = '!!!';`

Given a paragraph and a button. By clicking on the button, read the text of the paragraph and output it to the console.

Given a paragraph and a button. By clicking on the button, write a new text into the paragraph.

Given two paragraphs containing some numbers in their text, and a button. By pressing the button, display the sum of the stored numbers.

Given three paragraphs with numbers, a div, and a button. By pressing the button, write down the sum of numbers in the text of the div.

Given a paragraph with a number and a button. By clicking on the button, add one to the paragraph value and write the resulting number back.

Given a paragraph with text and a button. After pressing the button, write an exclamation mark at the end of the paragraph text.

←→
↑
en ru