Aya
Aya

Reputation: 41

How can I highlight certain options in a HTML select - using javascript

I saw this post:

How can I highlight certain options in a HTML select using jQuery

which is similar to what I need to do, except a bit too complicated for my understanding. In the html body, I have a dynamically changing select form. The user can select multiple items from this form, and click a button ("Display") to run a javascript function. This function already goes through the list to determine which ones have been selected and uses the information somewhere else.

I would like it so that when the user clicks "Display", the items that were selected will be highlighted (and each with a specific color).

What do you think?

Upvotes: 2

Views: 1243

Answers (1)

Aya
Aya

Reputation: 41

Yes! I figured it out.

myList.options[i].style.backgroundColor='yellow';

Upvotes: 2

Related Questions