How do I add style to content in JavaScript?

后端 未结 4 1783
独厮守ぢ
独厮守ぢ 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:16

    You could also just change a class to the element ..

    in the swapFE function

    phrase.className = 'english';
    

    and in the swapEF function

    phrase.className = 'french';
    

    and in your css file

    .english{ color:#9b6666; }
    .french{ font-style:italic; color:#000; }
    

提交回复
热议问题