LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

  
This allows you to add and/or remove classes after the user has scrolled down a certain amount in a page.








In this case, fill background with orange after scrolling 50px down.
CSS
body {
  height: 100%;
  width: 100%;
  background-color:lightblue;
}

.wrapper {
  width:800px;
  height:1500px;
  padding:15px;
  margin:0px auto;
}

#dynamic {
  width:500px;
  border:dashed white;
  border-radius:10%;
  padding:3em;
  font-family:helvetica, arial;
  font-weight:bold;
  font-size:1.5em;
  font-height:1.5em;
  margin:0px auto;
}

.newClass {
  border:none;
  background-color:orange;
}
JS
$(window).scroll(function(){
    if ($(this).scrollTop() > 50) {
       $('#dynamic').addClass('newClass');
    } else {
       $('#dynamic').removeClass('newClass');
    }
});
Host Instantly Drag and Drop Website Builder

 

Description

This allows you to add and/or remove classes after the user has scrolled down a certain amount in a page. In this case, fill background with orange after scrolling 50px down.
Term
Mon, 11/27/2017 - 21:37

Related Codes

Pen ID
Pen ID
Pen ID