We're a place where coders share, stay up-to-date and grow their careers.
We can use a check to see what values the input has at keyboard events. Then if it has empty string we can simply restore the original font-size of the mentioned classes.
font-size
Here is an approach to do so:
$(function() { $(".checker").on("keydown keyup", function(ev) { $(".js-cool, .js-beans").css("font-size", "24px"); $input_val = $(this).val(); if ($input_val == "") { $(".js-cool, .js-beans").css("font-size", "inherit"); } }); });
We can use a check to see what values the input has at keyboard events. Then if it has empty string we can simply restore the original
font-size
of the mentioned classes.Here is an approach to do so: