I have a simple jQuery function--detailed below-- that I'm using to manipulate the position of the document header, and I'm wondering if I can add a parameter such that the function is only executed if the browser window is of a certain size? In this case, I'd like the "stickyHeaderTop" function to execute only if the browser window width exceeds 1024px; is this possible?
<script type="text/javascript">
$(function(){
var stickyHeaderTop = $('header').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('header').css({position: 'fixed', top: '0px'});
} else {
$('header').css({position: 'relative', top: '30px'});
}
});
});
</script>
window.screen.availWidthattribute?