I
I
iscodenick2016-07-19 16:38:38
JavaScript
iscodenick, 2016-07-19 16:38:38

Why doesn't scrollTop jquery work in ie(11v)?

$(document).ready(function(){
$(window).scroll(function(){ // this part works
if($(this).scrollTop() > 300){
$('.totop').show (300)
}else{
$('.totop').hide(300)
}
});

var he1 = $('nav').height()*13;
var he2 = he1 + $('.t1') .height();
var he3 = he2 + $('.serv').height();

// This one doesn't. Should scroll on click...


$('.scroll1').click(function(){
$ ('body').animate({scrollTop : he1 }, 1500);
});

$('.scroll2').click(function(){
$('body').animate({scrollTop : he2 }, 1500 )
});

$('.scroll3').click(function(){
$('body').animate({scrollTop : he3 }, 1500)
});

$('.totop').click(function(){
$('body').animate({scrollTop: 0}, 500)
});
})

Why does this code work in chrome and not in IE?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2016-07-19
@iscodenick

$('html, body').animate({
    scrollTop: he1
}, 1500);

I
iscodenick, 2016-07-19
@iscodenick

Here is crap! The main thing was writing either html or body ... Separately, it did not work, but together it worked. Thank you)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question