Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Merging 2 filter functions with one If Else statement

$
0
0

I tried number of different combinations put 2 hours of attempts got me nowhere. How can I merge the 2 filter functions in one if .. else .. statement?

$('.app-layout .app-co .badge')
  .filter(function(){ return $(this).text() == 'Off'; })
  .addClass('bg-palette-yellow text-palette-dark-gray');

$('.app-layout .app-co .badge')
  .filter(function(){ return $(this).text() == 'On'; })
  .addClass('bg-palette-green text-palette-dark-gray');

Viewing all articles
Browse latest Browse all 138163

Trending Articles