In below example, i
is a variable. We want to make div
's background color automatically changes as the i
'value changes. How to add variable into class
tag in html?
.js
var i = 0;
i
will be changed after some processing.
.html
<div class="bgcolor+i"></div>
.css
.bgcolor0{
backgorund: red
}
.bgcolor1{
background: green
}
...