I have the following code:
<select id="fonts">
<option value = "Times New Roman">Times New Roman</option>
<option value = "Monospace">Monospace</option>
<option value = "Sans-Serif">Sans Serif</option>
<option value = "Arial">Arial</option>
</select>
<div id = "text"contenteditable = "true">
</div>
I want to use the document.execCommand() method where the font will change based off of the selected font name from the options list.
I've tried:
<option value = "Monospace" document.execCommand('fontName', true, Monospace)>Monospace</option>
But I can't seem to properly connect it with the options list and the result is nothing. How can I achieve the font changing depending on what you select with this method? I'm aware of using them with buttons but I'm curious if it's possible to achieve it with an options tag?