Another way to accomplish this is using only an adjacent selector.
.show-on-focus { display: none }
.searchtext:focus + .show-on-focus {
display: block;
}
If you have several elements that you want to hide, you can swap the position of an adjacent selector with a common selector.
.show-on-focus { display: none }
.searchtext:focus ~ .show-on-focus {
display: block;
}
Both are not as sexy as :not, but it will be slightly better compatible with older browsers.
source
share