gpt4 book ai didi

javascript - id.style 或 document.getElementById ('id' ).style

转载 作者:行者123 更新时间:2023-12-03 05:24:32 25 4
gpt4 key购买 nike

添加风格的最佳方式是什么?

使用

id.style.color = "green"document.getElementById('id').style.color = "green"

最佳答案

使用后一个选项:

document.getElementById('id').style.color = "green"

请参阅此答案以获取关于此问题的精彩文章:

It's generally considered bad practice to omit var, as well as to rely on named elements being visible on window or as globals. Stick to document.getElementById, which is more widely-supported and less ambiguous.

关于javascript - id.style 或 document.getElementById ('id' ).style,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41207642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com