I have certain code which copies <div> content to <textarea>, but then it doesnt copy the style (font family) of the <div>. It paste in the normal font. How do i fix this problem?
HTML
<input type="text" id="styledText" placeholder="Place your Name..." size="50" name="styledText" class="changeMe">
<div id="fontselect" class="changeMe" onClick="copyText()" style="font-family: Times New Roman;font-size: 22px; font-weight: bold; cursor:pointer;">Place your Name...</div>
Javascript
function copyText() {
var output = document.getElementById("fontselect").innerHTML;
document.getElementById("styledText").value = output;
}
Thanks in advance 🙂
Bearing in mind the
font-familywill apply to all of the inserted text, so any individually styled words/content will lose their differentiation: