7
Look at the examples below. I’m trying to style my CSS through value
that he has, but it’s not working.
I’ve put together three examples, one for input
has the [value="red"]
it should stick with a red border. But even you typing red
nothing changes in it, and if it already comes with the value defined as red
, even if you erase this value he continues with the red border.
I also did a test with select, already leaving an option with the option[value="3"]
selected using selected
tb CSS is not applied...
Is there any way to use the value
who is in the input and use it as selector to apply some class only with CSS?
[value="red"] {
border: 2px solid red;
}
select > option[value="3"] {
border: 2px solid red;
}
Digite "red" nesse input e nada acontece<br>
<input type="text" value="" />
<br><br>
Esse input já está com o value=red e o CSS funcionou, <b>mas se eu apagar ele continua com o estilo!</b><br>
<input type="text" value="red" /><br><br>
Esse Select já está com o option de value=3 selecionado, mas nada acontece<br>
<select name="qa_contact">
<option value="1">opt 1</option>
<option value="2">opt 2</option>
<option value="3" selected="selected">opt 3</option>
</select>
A while ago I asked a question in SO-EN on the same subject: How to select a Row that contains a column with a specific text?
– Marconi