matt
matt

Reputation: 44293

animated scroll with jquery?

hey guys, i just wrote a little function that filters all anchor links and animates a scroll to the found element.

i just wonder if there is anything i could do better? how would you do that? i'm actually quite happy with the solution, however maybe you'll find a rather bad-scripted part right away.

http://jsfiddle.net/ueXtq/3/

e.g. this part looks rather complicated and i wonder if theres a better way to filter the hashtag out of a href attribute?

anchor = $(this).attr('href').split('#')[1];

thank you for your tipps.

Upvotes: 0

Views: 227

Answers (1)

Shikiryu
Shikiryu

Reputation: 10219

I see 2 things :

I don't think you need .each().

I don't think you need to .split().

http://jsfiddle.net/ueXtq/4/

Upvotes: 1

Related Questions