I need to a add an icon from Fontawesome to an option of a selector. It works fine, unless I use optgroup
<select>
<optgroup label="group name">
<option>opt1 </option>
<option>opt2 </option>
</optgroup>
<option>opt3 </option>
<option>opt4 </option>
</select>
Here's JSfiddle.
Any ideas why?
I updated your fiddle to use external resources.
It imports a javascript file and a css file, and the icons show now.
If you make an account on FontAwesome they will send you a link. Try the below in your code and see if it works, I'm betting it will.
<link rel="stylesheet" type="text/css" href="https://fontawesome.io/assets/font-awesome/css/font-awesome.css">
<script type="text/javascript" src="https://use.fontawesome.com/cec949909c.js"></script>
Fiddle doesn't work on Windows 8.1 (latest FF + IE11), looks like there is something with the select from the OS. Even without optgroup it still does not work, so optgroupt has nothing to do with it.
Looks like this answer is still valid. Workaround: use jQuery plugins instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With