'Javascript access html select options and change background color of options [duplicate]

I have a <select> in my JSP page, I am populating it dynamically. I have stored the <select> in a javascript variable selectObj using JQuery.

selectObj = $("mySelectId");

How can I access the options? I want to change each option's background color.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source