JavaScript sets and modifies CSS styles

Syntax:
nodeObject.style.cssProperty=newStyle
Among them, nodeObject is the node object, cssProperty is the CSS property, and newStyle is the value of the CSS property.

Note: For CSS properties separated by "-", remove the "-" and capitalize the first letter after the "-".

For example:

document.getElementById("demo").style.height = "50px" ; document.getElementById("demo").style.border = " 1px solid #ddd "; document.getElementById("demo").style.backgroundColor = " #ccc "; document.getElementById("demo").style.textAlign = " center ";

For example, set the style of the node with id="demo":

 
点击这里改变CSS样式


Continuing Learning
||
无标题文档
点击这里改变CSS样式
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!