0

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

var chartDiv = document.createElement("div");
this.viewElement.appendChild(chartDiv);

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

2 Answers 2

1

Create a style you'd like your DIV to have:

div.bordered {
  border-style: dotted;
}

And then add the class to your DIV:

var chartDiv = document.createElement('div');
chartDiv.className = 'bordered';
this.viewElement.appendChild(chartDiv);

This will allow you to style your DIV better, and add more than just the border.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep thats a good answer, but the nature of it is to only be rendered in javascript, otherwise I would have leaned more on CSS. Jecoms provided me the answer though, but I appreciate the help anyway
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.