E
E
Egor Morozov2017-05-29 22:47:54
JavaScript
Egor Morozov, 2017-05-29 22:47:54

Disable script at certain screen resolution?

I messed up the up arrow on the site, you need to make sure that when the media value (max-width: 320px) is set, the script is disabled

<script type="text/javascript">
 
$(function() {
 
$(window).scroll(function() {
 
if($(this).scrollTop() != 0) {
 
$('#toTop').fadeIn();
 
} else {
 
$('#toTop').fadeOut();
 
}
 
});
 
$('#toTop').click(function() {
 
$('body,html').animate({scrollTop:0},800);
 
});
 
});

</script>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@kotmail, 2017-05-29
_

if(window.innerWidth > 320){

$(window).scroll(function() {
 
if($(this).scrollTop() != 0) {
 
$('#toTop').fadeIn();
 
} else {
 
$('#toTop').fadeOut();
 
}
 
});
 
$('#toTop').click(function() {
 
$('body,html').animate({scrollTop:0},800);
 
});

}

X
xmoonlight, 2017-05-29
@xmoonlight

without JS - no way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question