I used an id "changecolor" on all my paragraphs as well but doesn't
work.
If you're trying to change the background colour of all paragraphs, they should be identified using a Class -- not an ID. If you try to change the CSS of something with a ID, you'll only affect one of the elements on the page with that ID. Classes are meant to be used multiple times through out the page, as opposed to IDs which are meant to be uniqued and, therefore, only used once.
So, if you have a bunch of paragraphs called zalachenka for example, they'd look like this:
<p class="zalachenka">Here's my paragraph text where I want to change the background colour</p>
<p class="zalachenka">Here's my paragraph text where I want to change the background colour</p>
<p class="zalachenka">Here's my paragraph text where I want to change the background colour</p>
You could use getElementsByClassName to find all of these Classes, but that would generate an array of results and you would have to loop through them to assign the colours. To target the first element, you'd have to write your JavaScript like this:
document.getElementsByClassName('zalachenka')[0].style.backgroundColor = 'blue'
Since you have three (in the above example), you would have to loop through all of them.
const elems = document.getElementsByClassName('zalachenka') // returns array of elements.
for (let i = 0; i < elems.length; i++) {
elems[i].style.backgroundColor = 'blue' // loops through the array and assigns the background color to each element.
}
Keep in mind, this will assign CSS to the Tag inline. When the process is complete, the HTML will looks like this:
<p class="zalachenka" style="background-color: red;">Here's my paragraph text where I want to change the background colour</p>
<p class="zalachenka" style="background-color: red;">Here's my paragraph text where I want to change the background colour</p>
<p class="zalachenka" style="background-color: red;">Here's my paragraph text where I want to change the background colour</p>