I am trying to change the font of an aside, when you select the font you want to use from a drop down list.
However, the only value my code will pick up is for the first option of the list. When I click on another font, nothing happens. How do I get the other values selected? Thank you.
var fontVal = $("select option").attr("value"); alert(fontVal); function fontChoice(){ if(fontVal == "Choose"){ $('#mirror').css({"font-family":"sans-serif"}); console.log('Choose'); }else if(fontVal == "Arial"){ $('#mirror').css({"font-family":"Arial"}); console.log('Courier'); }else if(fontVal == "Times"){ $('#mirror').css({"font-family":"Times New Roman"}); console.log('Times'); }else if(fontVal == "Impact"){ $('#mirror').css({"font-family":"Impact"}); console.log('Impact'); }else if(fontVal == "Courier"){ $('#mirror').css({"font-family":"Courier"}); console.log('Courier'); }; }; fontChoice(); <aside id="mirror"> </aside> <select id="fonts"> <option value="Choose">Choose your font</option> <option value="Arial">Arial</option> <option value="Times">Times New Roman</option> <option value="Impact">Impact</option> <option value="Courier">Courier</option> </select>