Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify SELECT tag's default highlight behaviour in IE and Opera?

Here is my HTML:

<select style="background-color:#e0f0f1">
  <option selected="selected">Select</option>
  <option class="" value="one">One</option>
  <option class="" value="two">Two</option>
</select>

See this code in action

In IE and Opera, when you select an option, it is highlighted with a blue background colour. Firefox, Chrome and Safari don't do this. Is there a way or trick to remove that blue highlight when the option is selected so that the original background colour is always shown?

If that's not possible, is there a way to add a jQuery behaviour that simulates a click elsewhere on the page right after the option is selected? So basically when you click away from the selected option, the highlight disappears.

like image 918
user1448031 Avatar asked Nov 01 '12 02:11

user1448031


1 Answers

In IE11 (not sure about previous versions) you can remove the blue background from a focused select element with

select::-ms-value {background: none;}

Here's a dabblet demo

like image 154
willrice Avatar answered Oct 20 '22 00:10

willrice