Skip to content

Instantly share code, notes, and snippets.

@Alex-Space
Last active August 29, 2015 14:25
Show Gist options
  • Save Alex-Space/517b075818c2c1ba26ef to your computer and use it in GitHub Desktop.
Save Alex-Space/517b075818c2c1ba26ef to your computer and use it in GitHub Desktop.
doc jQuery
// Сделать высоту блоков такой, какая у самого высокого
function make_the_higher() {
var elementHeights = $('.main-posts .post-box').map(function() {
return $(this).height();
}).get();
// Math.max takes a variable number of arguments
// `apply` is equivalent to passing each height as an argument
var maxHeight = Math.max.apply(null, elementHeights);
// Set each height to the max height
$('.main-posts .post-box').height(maxHeight);
}
make_the_higher();
// Сделать скролл к элементу по клику на него
$('.header-tab-elem').live( 'click', function() {
$(window).scrollTop( $(this).offset().top );
});
// Сделать то же самое но плавно
$('html, body').animate({scrollTop: ЭЛЕМЕНТ_К_КОТОРОМУ_СКОЛЛИМ.offset().top}, 300);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment