Add css inline style using JavaScript

Add inline css style using JavaScript via document.createElement.

var style = document.createElement('style');
style.textContent = '.alert { color: red; };';
document.head.appendChild(style);
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment