Issue
I want to get all the paragraph tags on a page to be white by putting something into the console. I tried something like this:
document.p.style.color = 'white';
but that did not work. I know changing the body tag works in the console tho
document.body.style.background = 'black';
Solution
You would need to select paragraph individually or select them in bulk to change their properties.
Since there is only 1 body
document.body
worksBut there can be multiple paragraphs so
You either need to select them by thier id `**
document.getElementById("Id")
**` or you could do **
document.querySelectorAll('p').forEach(p => p.style.color = 'white');
**
Answered By - Aqdas Ali
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.