How do I add style to content in JavaScript?

后端 未结 4 1782
独厮守ぢ
独厮守ぢ 2021-01-13 08:02

I have been working in a JavaScript file and my content has been working with phrases. Now I want to change the style of those phrases. The first function (see function swap

4条回答
  •  悲&欢浪女
    2021-01-13 08:23

    Using element.style you can change css from Javascript.

    For example:

    document.getElementById('mydiv').style.backgroundColor = 'red';
    

    And to help you find the exact syntax for the attribute, here's CSS Properties To JavaScript Reference Conversion.

提交回复
热议问题