Last active
March 30, 2021 18:12
-
-
Save divienginesupport/b6851103141499f2a6e729e5e89ef456 to your computer and use it in GitHub Desktop.
Sample jQuery that can be added to Divi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
jQuery(document).ready(function( $ ) { // When jQuery is ready | |
function check_from_top_de(){ // Create our function | |
var scroll = $(window).scrollTop(); // Check scroll distance | |
if (scroll >= 300) { // If it is equal or more than 300 - you can change this to what you want | |
$("#your-target-element").addClass("class-to-be-added"); // Add custom class to body | |
} else { | |
$("#your-target-element").removeClass("class-that-we-added"); // When scrolled to the top, remove the class | |
} | |
} | |
check_from_top_de(); // On load, run the function | |
$(window).scroll(function() { // When scroll - run function | |
check_from_top_de(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment