I am having trouble understanding some CSS effects. For example; how can I change the font color based on a text box value?
Here’s my scenario:
On the HTML page:
<div id=”dv1” class=”firstDiv”>
<input type=”text” id=”tb1” class=”txtbx1” >
</div>
On the CSS page
.txtbx1 {
Color: red;
}
.txtbx1:has(“Open”) {
Color: green;
}
I’ve tried “has” and “contains” but neither work.
I also tried doing the change on the whole div, but that didn't work either.
The value in the text box changes automatically (through some javascript) based on the time of day and not from a user input.
So, from 9am to 5pm, the value is “Open”, but from 5:01pm to 8:59am the text box value is “Closed”.
I can get it to change color on hover or by clicking a button, but I want it to change automatically with the changing of the text value, open or closed.
Is this possible?
Thanks.