1

I've tried a few solutions, and nothing seems to work. After onLoad is called on my code, I try to scroll to a specific class (This is dynamic. Sometimes I try to scroll, other times not).

I have JQuery loaded and am trying to use $("." + className).get(0).scrollIntoView();, but again it's not working. Has anyone been able to get this working? There is plenty I don't know about common javascript libraries, or ways to do things. Any help is appreciated.

4

1 回答 1

0

最终使用以下javascript:

function scrollToClass(className) {
var elements = $("." + className);
elements.addClass("search-result")

var height = elements.offset().top;
if (height < 0)
    height = 0;

$("html, body").animate({
     scrollTop: height
}, 500);
}
于 2013-07-20T00:37:52.427 回答