Last active
May 1, 2018 09:38
-
-
Save ThomasLarge/5edcc71c9accfb038933434e0318d522 to your computer and use it in GitHub Desktop.
JQuery snippets
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
// clickable divs | |
jQuery(".click-me").click(function(){ | |
window.location=jQuery(this).find("a").attr("href"); | |
return false; | |
}); |
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
// open all external links in blank | |
jQuery(document).ready(function() { | |
jQuery("a[href^=http]").each(function(){ | |
if(this.href.indexOf(location.hostname) == -1) { | |
jQuery(this).attr({ | |
target: "_blank", | |
}); | |
} | |
}) | |
}); |
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
// Fade out on scroll | |
jQuery(window).scroll(function(){ | |
jQuery(".fadeoutup").css("opacity", 1 - jQuery(window).scrollTop() / 550); | |
}); |
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
// If the url has a # if else | |
if(window.location.hash) { | |
// Fragment exists | |
} else { | |
// Fragment doesn't exist | |
} |
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
// This is where all of the snippets for jQuery lives |
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
// Scrolly | |
jQuery(".scrolly").click(function(scroll1){ | |
scroll1.preventDefault(); | |
jQuery('html,body').animate({scrollTop:jQuery(this.hash).offset().top -85 | |
}, 1000); | |
}); |
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
$('.waypoint-fadeInLeft').css('opacity', 0); | |
$('.waypoint-fadeInLeft').waypoint(function(){ | |
$(this).addClass('fadeInLeft'); | |
},{ | |
offset:'90%', | |
triggerOnce:true | |
}); | |
$('.waypoint-fadeInRight').css('opacity', 0); | |
$('.waypoint-fadeInRight').waypoint(function(){ | |
$(this).addClass('fadeInRight'); | |
},{ | |
offset:'90%', | |
triggerOnce:true | |
}); | |
$('.waypoint-fadeInUp').css('opacity', 0); | |
$('.waypoint-fadeInUp').waypoint(function(){ | |
$(this).addClass('fadeInUp'); | |
},{ | |
offset:'90%', | |
triggerOnce:true | |
}); | |
$('.waypoint-fadeIn').css('opacity', 0); | |
$('.waypoint-fadeIn').waypoint(function(){ | |
$(this).addClass('fadeIn'); | |
},{ | |
offset:'90%', | |
triggerOnce:true | |
});\ | |
$('.waypoint').css('opacity', 0); | |
$('.waypoint').waypoint(function(){ | |
$(this).animate({opacity:1},"slow"); | |
},{ | |
offset:'90%', | |
triggerOnce:true | |
}); |
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
// Wrap class with a new class | |
jQuery( ".entry-content img" ).wrap( "<div class='img-wrap'></div>" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment