Skip to content

Instantly share code, notes, and snippets.

@JRyven
Last active September 28, 2020 09:56
Show Gist options
  • Save JRyven/8c00a5b1e1410c3bc6f970f3117d5506 to your computer and use it in GitHub Desktop.
Save JRyven/8c00a5b1e1410c3bc6f970f3117d5506 to your computer and use it in GitHub Desktop.
jQuery Examples for Resizing
<script>
jQuery(document).ready(function($) {
// Set all Elms to Height of Tallest
function setEqualHeight(e) {
var t = 0;
e.each(function(){
currentHeight = $(this).height();
if (currentHeight > t) {
t = currentHeight
}
});
e.height(t)
}
// On Window Resize
$(window).resize(function () {
// Unset All Heights
$('.TARGET_ELEMENTS').css('height', '');
// If Screen Width is "Wide"
var screen_width = $(window).width();
if (screen_width > 1280){
// Call setEqualHeight
setEqualHeight($('.TARGET_ELEMENTS'));
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment