Ive been looking around but have had no luck is it possible (with css) to target the body tag on input:focus so for example when someone clicks on the input box i want the body to have background:red, im not sure if this is actually possible.
Thanks in advance.
Connor
This will be possible in the future with the CSS4 parent selector, but for now you would have to use JavaScript.
This is not possible with CSS. But it can be easily achieved with javascript / jQuery :)
This is how to do it in jQuery,
$("input[type=text]").focus(function() {
$("body").css({"background-color" : "red"});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With