D3.js Template

by gleezer

HTML

<div id="g1"></div>
  <div id="g2"></div>
  <div id="g3"></div>
  <div id="g4"></div>

CSS

div {
  display: inline-block;
  height: 20px;
  width: 300px;
  background: teal;
}
.red {
  background: red;
}

JavaScript

var ids = ['#g1', '#g2']

ids.map(el => d3.select(el).classed('red', true));