jQuery scrollLeft in IE9

此生再无相见时 提交于 2020-01-07 05:26:06

问题


Okay, I got an div#outer with a width of 200px e.g.
In this div is another wider div, which has a width of 1200px.

To keep it simple this values are fix, in real this will be calculated.

The outer div has "overflow:scroll" so the user can scroll from left to right.
On init the inner div scrolls to a specific position.
This all works good, but why not in IE9 ?

I've made a fiddle, eventually someone has an idea whats going on in IE there.

http://jsfiddle.net/3GZYy/1/

var scrollOffset = parseInt(1255.3453 - 422.3453);

$('#outer').animate({
    scrollLeft: scrollOffset
}, 250, function() {
    // animation is over
    // createChartNavi();
});

回答1:


Your console.log is causing IE9 not to run the animation, try removing it:

$(function() {
    // Handler for .ready() called.


    // is ready
    var scrollOffset = parseInt(1255.3453 - 422.3453);

    $('#outer').animate({
        scrollLeft: scrollOffset
    }, 250, function() {
        // animation is over
        // createChartNavi();
    });
});

DEMO



来源:https://stackoverflow.com/questions/24384923/jquery-scrollleft-in-ie9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!