How to change the background color of an HTML element with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>

<p id="pid">Text text text</p>

<input type="button" value="Set background color" 
onclick="document.getElementById('pid').style.background='yellow'">

</body>
</html>

 



answered Jan 15, 2019 by avibootz

Related questions

3 answers 413 views
1 answer 234 views
1 answer 246 views
1 answer 247 views
1 answer 246 views
1 answer 208 views
...