EJS inside of Style

Viewed 186

I want to manipulate width depending on information from the server by inputting ejs tags there but I can't figure out how. Is there a way to do something similar?

<div class="progress">
  <div class="progress-bar progress-bar-striped infoTxt" style="width:40%">energy</div>
</div>
2 Answers

You can do it using ejs like this:

use <%= widthfromserver %> in place of 40%

I would create a seperate script tag and adjust the styling that way.

document.getElementByClassname("progress-bar").style.width = width + '%';

Alternatively you can use the following syntax

<div class="progress">
  <div class="progress-bar progress-bar-striped infoTxt" style="width:<%= width %>%">energy</div>
</div>
Related