My page has two textareas and a div. One textarea is for the user to enter html and the other is for entering css. When a button is clicked I will call a javascript function to display the css and html inside the div.
function handleLaunch() {
var div = document.getElementById('pane');
var html = document.getElementById('h');
var css = document.getElementById('c');
div.innerHTML = html.value;
// This line obviously doesn't work div.style = css.value;
}
<body>
<textarea id="c" placeholder="CSS code here..." rows="10" cols="50"></textarea>
<div id="pane">
</div>
<br>
<textarea id="h" placeholder="Html code here..." rows="10" cols="50"></textarea>
<br>
<button type="button" onclick="handleLaunch()">Launch</button>
Now, how to set the css to the text ?
EDIT: I should have mentioned that I want to be able to put something like .classExample{text-align:center} in the css textarea and have it apply.
div.style.cssText = css.valuewould let you type CSS in the input