How can I make a textarea which has the stylesheet of the web page inside it?
I want to make a web page which a user can customize its <style> settings by editing text inside a textarea.
Here's what I have done so far; inside the <textarea> of this code snippet is the editable text which I intend to make it function as the web page's stylesheet, but I'm not sure how to make it work.
I did many web search looking for solutions, but could not find useful help regarding this particular function. Any help will be appreciated.
function myFunction() {
document.getElementsByTagName("style")[0].innerHTML = "document.getElementById('input').value;";
}
<p>sample text</p>
<textarea id="input" oninput="myFunction()" rows="5">p {
font-family: monospace;
font-size: 15px;
}
</textarea>