Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Jquery Page scroll.

Featured Replies

Hey, I'm trying to get jquery to scroll the page to certain anchors.

 

Does anyone know of a plugin, or can write code that would work in this context. Keep in mind that the header is static, and its only the content div that scrolls, sort of acting like an iframe I guess.

 

http://qwibbledesigns.co.uk/preview/wood/

 

Any ideas? =)

  • Author

<script type="text/javascript">
$(document).ready(function() {
$('.scrollPage').click(function() {
  var elementClicked = $(this).attr("href");
  var destination = $(elementClicked).offset().top;
  $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 500 );
  return false;
});
});
</script>

 

I tried this one, but am aware that I need to target the div#content area rather than the body. However, when I substitute html for div#content, the first scroll works, and thereafter it scrolls to seemingly random places on the page. Does anayone know how to make it target just the div#content?

  • Author

Okay, so it does actually work, but you need to reclick the link to resend it back to the top of the page, before you can click a new link which is far from useable.

Just out of curiosity, why did you choose to make the div scrollable, as opposed to just fixing the position of the header?

 

Fixing the position of the header would prevent double scrollbars on smaller resolutions, plus it creates the same effect even when js is disabled?

 

Anyway,

 

Have a look at this http://jqueryfordesi...-slider-effect/

 

You're effectively doing the same, except vertically as opposed to horizontally.

 

Their are tons of plugins about to do this kind of thing, such as scrollTo/LocalScroll. You can see an example of it implemented here

 

http://themeforest.n...n_preview/34008

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.