Is there a way to detect whether or not an input has text in it via CSS? I've tried using the :empty
pseudo-class, and I've tried using [value=""]
, neither of which worked. I can't seem to find a single solution to this.
I imagine this must be possible, considering we have pseudo-classes for :checked
, and :indeterminate
, both of which are kind of similar thing.
Please note: I'm doing this for a "Stylish" style, which can't utilize JavaScript.
Also note, that Stylish is used, client-side, on pages that the user does not control.
Simple Trick with jQuery and CSS Like so:
JQuery:
CSS:
Simple css:
This code is going to apply the given css if the input is filled up.