问题描述:

How do I select the div with the link in and make an animation run when the link is clicked?

Here is the html code and script:

<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>

The script:

$(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();

});

});

相关阅读:
Top