trigger function at certain window width

by lovromar

HTML

Resize me!

JavaScript

$(window).on('resize', function(event){
	var windowSize = $(window).width(); // Could've done $(this).width()
    if(windowSize < 300){
    	$('html').css('background-color', 'red');
        console.log('<'+300);
    } else if(windowSize < 768){
    	$('html').css('background-color', 'yellow');
        console.log('<'+768);
    } else {
    	$('html').css('background-color', 'blue');
        console.log('other');
    }
});