$(window).resize(function() {
$('div#navigation ul li br').toggle( $(this).height() >= 768 );
});
.toggle()takes a boolean parameter that determines whether hidden elements should be hidden (jQuery uses CSS display: none;) or shown.
In this case, the window height is used to calculate the logical value.
Premature optimization: if for some reason you are sluggishly tuned, you can optimize it by first selecting breaks and remembering the state to decide what to do first:
$(window).resize( (function () {
var $window = $(window),
$navigationBreaks = $('div#navigation ul li br'),
prevState = isLargeWindow();
function isLargeWindow() {
return $window.height() >= 768;
}
return function () {
var newState = isLargeWindow();
if (newState == prevState) return;
$navigationBreaks.toggle(newState);
prevState = newState;
};
})() );
This is a lot more code, much more complicated, and maybe a few milliseconds faster than a single line approach. Take it with salt.