关于js中修改css样式的问题?
check
check 2016-12-22 16:56:27
0
2
1379

获取标签对象 obj

obj.style="background-color:red"

obj.style="backgroundColor:red"

这两种 那种 对   为啥都没反应???


check
check

Antworte allen(2)
数据分析师

关于js中修改css样式的问题?-PHP中文网问答-关于js中修改css样式的问题?-PHP中文网问答

围观一下哦,学习一下。

迷茫

obj.style="background-color:red"

obj.style="backgroundColor:red"

上述写法是混淆了CSS和DOM(具体说来就是javascript)这两个内容的语法规则。在CSS中,设置背景颜色可以在标签中的属性设为“background-color:red”。而在DOM中,设置背景颜色,需要用到属性sty.backgroundColor,将其设置为red,而且写法为:“obj.style.backgroundColor="red";”


Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!