Monday 16 December 2019

html - CSS: Target body on Input:focus




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


Answer



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"});
});


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...