我正在测试scrollTop方法,但它没有正常播放。当我点击一个段落元素时,顶部的滚动顺利运行。我到了#map元素但是我无法在点击事件后滚动。窗口不向下滚动。这是你要看的js代码。
jQuery('area').each(function(){
var values =jQuery( this ).attr('data-nid');
jQuery( this ).append('<p>'+values+'</p>');
jQuery( this ).closest("#membermap").find('p').click(function () {
$("html, body").animate({
scrollTop: $("#map").offset().top
}, 600);
return false;
});
});
这是我的HTML代码:`
<map class="imagemap" id="membermap" name="membermap">
<area data-nid="513" shape="circle" alt="" title="" coords="54,173,3" href="" target=""></area>
<area data-nid="566" shape="circle" alt="" title="" coords="76,181,3" href="" target=""></area>
<area data-nid="490" shape="circle" alt="" title="" coords="73,189,3" href="" target=""></area>
<area data-nid="715" shape="circle" alt="" title="" coords="115,205,3" href="" target=""></area>
<area data-nid="717" shape="circle" alt="" title="" coords="132,212,3" href="" target=""></area>
<area data-nid="481" shape="circle" alt="" title="" coords="96,224,3" href="" target=""></area>
<area data-nid="476" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="476" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="476" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="715" shape="circle" alt="" title="" coords="115,205,3" href="" target=""></area>
<area data-nid="717" shape="circle" alt="" title="" coords="132,212,3" href="" target=""></area>
<area data-nid="481" shape="circle" alt="" title="" coords="96,224,3" href="" target=""></area>
<area data-nid="456" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="426" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="456" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="730" shape="circle" alt="" title="" coords="115,205,3" href="" target=""></area>
<area data-nid="753" shape="circle" alt="" title="" coords="132,212,3" href="" target=""></area>
<area data-nid="42" shape="circle" alt="" title="" coords="96,224,3" href="" target=""></area>
<area data-nid="246" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="426" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
<area data-nid="473" shape="circle" alt="" title="" coords="133,315,32" href="" target=""></area>
</map>
`