通过控制台更改段落标签颜色
我想通过将某些内容放入控制台上,将所有段落标签放在页面上是白色的。我尝试了这样的事情:
document.p.style.color = 'white';
但是那无效。我知道更改身体标签在控制台中起作用
document.body.style.background = 'black';
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';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您答案的示例代码:
html:
js:
给您的课程和文本,而不是 nothing_you_want 和您的变量名称,而不是variable_name ...
Here is an example code for your answer:
HTML:
JS:
Give your class and text instead of ANYTHING_YOU_WANT and your variable name instead of VARIABLE_NAME...
您需要单独选择段落或批量选择它们以更改其属性。
您要么需要通过其ID选择它们
document.queryselectorall('p')。foreach(p => p.style。 color ='White');
You would need to select paragraphs individually or select them in bulk to change their properties.
You either need to select them by their id
document.querySelectorAll('p').forEach(p => p.style.color = 'white');