我不能仅通过链接使用select选项元素进行流畅的滚动。谁能帮我?
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
谢谢!
做就是了:
$('select').on('change', function () {
$('html,body').animate({
scrollTop: $(this.value).offset().top
}, 1000);
});
并删除onchange内联属性
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句