Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
How to show the option with a value=0 with red background using CSS and/or jQuery, no matter if it is selected or not?

I have tried simple CSS solutions, as well as a combination of both CSS and jQuery. The problem is that they show the option with the 0 value in red only when it is not selected.

.red {
  background: red;
}

select option[value=0] {
  background: red;
}
<select id="ups">
  <option value=0 class="red" selected="selected">No</option>
  <option value=1>Yes</option>
</select>

I have already conducted extensive search, so please any help is appreciated. Thanks.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I guess it depends on the browser, on firefox I can't see anything with red background, even not selected.

There is a similar question here: How to style the option of an html "select" element?

People linked this: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_custom_select

I don't think done in this way that can work for only one of the options. Yet you can make it when one is selected('No' for example) background for the whole thing to go red. Not perfect, but as close as possible I think that will work on most popular browsers.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda