javascript - Smooth scrolling page jump -


i need help.

i tried make simple project on jsfiddle, can't work. http://jsfiddle.net/reuyp/2/

here's code

html:

<div id="img0">     <b class="i01">one</b> <b class="i02">two</b> <b class="i03">three</b> </div>  <div style="width:200px; height:500px; background-color:red;" id="i01"></div> <br>  <div style="width:200px; height:500px; background-color:blue;" id="i02"></div> <br>  <div style="width:200px; height:500px; background-color:green;" id="i03"></div> <br> 

javascript:

$(function(){     $('#img0 b').click(function(){         cl=$(this).attr('class')         st=$('#'+cl+'').offset().top;                $('body,html').animate({scrolltop: st}, 500);         return false;     }); }); 

what want when click on 1 of words, page should scroll corresponding colored div. doesn't...

what missing? i'm sure it's stupid thing...

oh, , there better way accomplish this?

since using jquery, have include jsfiddle project. select in top left corner , sample work.

also in own project have include jquery eg:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 

inside head part of html page.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -