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.

Scroll To Jquery issue

Featured Replies

Im trying to get this 'scroll-to' jquery script to work but its not happening for some reason. Here is the tutorial http://gazpo.com/2012/03/horizontal-content-scroll/

 

and here is my html nd css. Any ideas?

 

html

<!DOCTYPE html>
<html>
<head>
<title>PW</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
function goto(id, t){
   //animate to the div id.
   $(".contentBoxWrapper").animate({"left": -($(id).position().left)}, 600);

   // remove "active" class from all links inside #nav
   $('#nav a').removeClass('active');

   // add active class to the current link
   $(t).addClass('active');
}
</script>
</head>
<body>
<!-- Header Section -->
<div id="headerContainer">
 <div id="header"><a href="#" id="logo"><img src="img/logo.png" /></a></div>
</div>
<!-- Navigation Section -->
<div id="nav">
 <div id="navHome"><a class="active" href="#" onclick="goto('#home', this); return false"><img src="img/navHome.png" /></a></div>
 <div id="navShop"><a href="#" onclick="goto('#shop', this); return false"><img src="img/navShop.png" /></a></div>
 <div id="navContact"><a href="#" onclick="goto('#contact', this); return false"><img src="img/navContact.png" /></a></div>
</div>
<!-- Content Section -->
<div id="content">
 <div class="contentBoxWrapper">
  <div id="home" class="contentBox">
   <h1>Home</h1>
   <p>This will be the home page</p>
  </div>
  <div id="shop" class="contentBox">
   <h1>Shop</h1>
   <p>This will be the shop page</p>
  </div>
  <div id="contact" class="contentBox">
   <h1>Contact</h1>
   <p>This will be the contact page</p>
  </div>
 </div>
</div>

</div>
<div id="title"></div>

<div id="controlContainer"></div>
</body>
</html>

 

css

* {
margin: 0;
padding: 0;
}
html {
padding: 10px;
background: #FFF;
}
body {
background-image: url("../img/bg.png");
}
/* ---------- Header Section ---------- */
#headerContainer {
height: 57px;
background: #FFF;
}
#header {
width: 940px;
height: 57px;
padding: 0px 20px;
margin: 0 auto;
}
#header #logo:hover {
opacity:0.8;
}
a img {
border: none;
}
/* ---------- Navigation Section ---------- */
#nav {
width: 940px;
height: 30px;
padding: 0px 20px;
margin: 0 auto;
position: relative;
}
#navHome {
width: 116px;
height: 42px;
position: absolute;
top: -4px;
left: 450px;
}
#navShop {
width: 116px;
height: 42px;
position: absolute;
top: -4px;
left: 620px;
}
#navContact {
width: 182px;
height: 42px;
position: absolute;
top: -4px;
left: 780px;
}
#navHome:hover {
opacity:0.8;
}
#navShop:hover {
opacity:0.8;
}
#navContact:hover {
opacity:0.8;
}
#title {
height: 101px;
margin: 69px 0px 0px 0px;
border-bottom: solid 50px #FFF;
}
/* ---------- Control Section ---------- */
#controlContainer {
width: 940px;
height: 300px;
padding: 0px 20px;
margin: 0 auto;
}
#content{
   overflow: hidden;
   -moz-box-shadow: 0 0 2px 2px #ccc;
   -webkit-box-shadow: 0 0 2px 2px #ccc;
   box-shadow: 0 0 2px 2px #ccc;
}

.contentBoxWrapper{
   position: relative;
   left: 0;
   width: 900px;
}

.contentBox{
   width: 580px;
   float: left;
   padding: 10px;
   background: #fff;
}
#nav a.active {
font-weight:bold;
}

i dont think your linking to jquery correctly

 

//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

change to

http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

Please, upload your code and share link here.. :) so easily, we could fix your issue :)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PW</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
<style>
* {
margin: 0;
padding: 0;
}
html {
padding: 10px;
background: #FFF;
}
body {
background-image: url("../img/bg.png");
}
/* ---------- Header Section ---------- */
#headerContainer {
height: 57px;
background: #FFF;
}
#header {
width: 940px;
height: 57px;
padding: 0px 20px;
margin: 0 auto;
}
#header #logo:hover {
opacity:0.8;
}
a img {
border: none;
}
/* ---------- Navigation Section ---------- */
#nav {
width: 940px;
height: 30px;
padding: 0px 20px;
margin: 0 auto;
position: relative;
}
#navHome {
width: 116px;
height: 42px;
position: absolute;
top: -4px;
left: 450px;
}
#navShop {
width: 116px;
height: 42px;
position: absolute;
top: -4px;
left: 620px;
}
#navContact {
width: 182px;
height: 42px;
position: absolute;
top: -4px;
left: 780px;
}
#navHome:hover {
opacity:0.8;
}
#navShop:hover {
opacity:0.8;
}
#navContact:hover {
opacity:0.8;
}
#title {
height: 101px;
margin: 69px 0px 0px 0px;
border-bottom: solid 50px #FFF;
}
/* ---------- Control Section ---------- */
#controlContainer {
width: 940px;
height: 300px;
padding: 0px 20px;
margin: 0 auto;
}
#content{
    overflow: hidden;
    -moz-box-shadow: 0 0 2px 2px #ccc;
    -webkit-box-shadow: 0 0 2px 2px #ccc;
    box-shadow: 0 0 2px 2px #ccc;
 width:600px;
 margin:0px auto;
}
.contentBoxWrapper{
    position: relative;
    left: 0;
    width: 3000px;
}
.contentBox{
    width: 580px;
    float: left;
    padding: 10px;
    background: #fff;
}
#nav a.active {
font-weight:bold;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
function goto(id, t) {
    //animate to the div id.
    $(".contentBoxWrapper").animate({"left": -($(id).position().left)}, 600);
    // remove "active" class from all links inside #nav
    $('#nav a').removeClass('active');
    // add active class to the current link
    $(t).addClass('active');
}
</script>
</head>
<body>
<!-- Header Section -->
<div id="headerContainer">
 <div id="header"><a href="#" id="logo"><img src="img/logo.png" /></a></div>
</div>
<!-- Navigation Section -->
<div id="nav">
 <div id="navHome"><a class="active" href="#" onclick="goto('#home', this); return false"><img src="img/navHome.png" />home</a></div>
 <div id="navShop"><a href="#" onclick="goto('#shop', this); return false"><img src="img/navShop.png" />shop</a></div>
 <div id="navContact"><a href="#" onclick="goto('#contact', this); return false">contact<img src="img/navContact.png" /></a></div>
</div>
<!-- Content Section -->
<div id="content">
 <div class="contentBoxWrapper">
  <div id="home" class="contentBox">
    <h1>Home</h1>
    <p>This will be the home page</p>
  </div>
  <div id="shop" class="contentBox">
    <h1>Shop</h1>
    <p>This will be the shop page</p>
  </div>
  <div id="contact" class="contentBox">
    <h1>Contact</h1>
    <p>This will be the contact page</p>
  </div>
 </div>
</div>
</div>
<div id="title"></div>
<div id="controlContainer"></div>
</body>
</html>

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.