To change or set a font style for certain text, the fontFamily CSS property needs to be changed. The fontFamily property sets or returns a list of font-family names for text in an element.
object.style.fontFamily = "font"
To change the font style by option dropdown: The font values can be passed in option tags using option value.
- Before selecting any option (Initial value – Times New Roman):
- After selecting an option in dropdown:
- After selecting another option in dropdown: