如何选择带有链接的 div 并在单击链接时运行动画?
这是html代码和脚本:
<div class="section white" id="work">
<div class="maincontent2"></div>
<section class="main">
<ul class="ch-grid">
<li>
<div class="ch-item">
<div class="ch-info">
<div class="ch-info-front ch-img-1"></div>
<div class="ch-info-back" id="graphiccircle">
<h3><a href="index.html#graphicdesign">Graphic Design</a></h3>
<p>Graphic/Typography<a href="index.html#graphicdesign">View</a></p>
</div>
</div>
</div>
</li>
</ul>
</section>
</div>
剧本:
$(function() {
$('').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left, scrollTop: $($anchor.attr('href')).offset().top
}, 1500,'easeInOutExpo');
event.preventDefault();
});
});