Whirlwind991 Whirlwind991 - 6 months ago 34
Javascript Question

Adding style to a div created in javascript

Quick question, I've got a div being created in javascript:

var chartDiv = document.createElement("div");

But I want to set a border style around this div after its created. Whats the best way to do this in the javascript?


Use the element style object.

chartDiv.style.border = "thin solid #FFF";

Alternatively, just add a css class to your element that contains the styling you want.