I Want To Change Css Style Using Javascript
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
Solution 1:
Try the following instead:
textArea.style.fontSize = fontSize ;textArea.style.fontFamily = fontType;
Otherwise your JavaScript is evaluated as:
textArea.style.font - size = fontSize;
textArea.style.font - family = fontType;
... which doesn't make any sense (and so throws a ReferenceError: Invalid left-hand side in assignment
).
This conversion (something-something
to somethingSomething
) is consistent when changing all style properties in JavaScript (border-radius
-> borderRadius
etc).
Solution 2:
Try:
textArea.style.fontSize = fontSize ;textArea.style.fontFamily = fontType;
Post a Comment for "I Want To Change Css Style Using Javascript"