score:0

Accepted answer

add .classed('classname', true)

<!doctype html>
<html>
<head>
  <script src="https://d3js.org/d3.v4.min.js"></script>
  <style>
    .error {
      color: #ff0000;
    }
  </style>
</head>
<body>
<p>error: this is dummy error.</p>
<script>
  // to add
  d3.select("p").classed("error", true);
</script>
</body>
</html>

enter image description here


Related Query

More Query from same tag