See this fiddle.
enquire.register("screen and (max-width: 640px)", {
match: function () {
$("body").css("background","red");
},
unmatch: function () {
$("body").css("background","blue");
}
});
when the browser window is 640px or less on load then the background-color will be set to red. (i.e. the match event is called). However, when the window is wider than 640px on load, nothing happens, i.e. the unmatch event is not called. Why not? And is there a way to force the unmatch event to fire if there is no match with the condition?
Basically what I want is that enquire behaves as an if-else statement that is immediatelly called.