markdown guide
 

Change:

if ($element.filter('.js-cool, .js-beans')) {

to

if ($element.filter('.js-cool, .js-beans').length) {

.filter returns an Array, which inherits from Object, and all Objects are truthy in JavaScript.

 
 

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:

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

Why looping over all objects and filter out then when you can start with a beter filter.

$('.js-cool, .js-beans').each(function() {
    $(this).css("font-size", "24px");
});
Classic DEV Post from Dec 12 '18

Will Java Trend Towards Obscurity?

I'm forking another conversation: ...

John Costanzo profile image
An EmberJs Developer who loves to build web apps