I want to append font style and type in textarea as per user requirement. I tried but my script is not working…
function run() {
var fontType = document.getElementById("font_type").value;
var fontSize = document.getElementById("font_size").value;
var textArea = document.getElementById("msg");
//alert(fontType+fontSize);
textArea.style.font-size = fontSize ;
textArea.style.font-family = fontType;
}
Try the following instead:
Otherwise your JavaScript is evaluated as:
… which doesn’t make any sense (and so throws a
ReferenceError: Invalid left-hand side in assignment).This conversion (
something-somethingtosomethingSomething) is consistent when changing all style properties in JavaScript (border-radius->borderRadiusetc).