Skip to content

Instantly share code, notes, and snippets.

@TeamBug99
Created September 22, 2021 19:12
Show Gist options
  • Save TeamBug99/f7027cfaa9655420a6a3996a7ddaad8d to your computer and use it in GitHub Desktop.
Save TeamBug99/f7027cfaa9655420a6a3996a7ddaad8d to your computer and use it in GitHub Desktop.
Basic jQuery
last 2 child add class
------------------------
$('ul.menu>li').slice(-2).addClass('last-elements');
lenth
---------
if ($(".active").length) {
$(".active").dropify();
}
data background
---------------
$("[data-background]").each(function () {
$(this).css("background-image", "url(" + e(this).attr("data-background") + ")")
});
isotop active
--------------
// filter items on button click
$('.portfolio-menu').on( 'click', 'button', function() {
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});
// init Isotope
var $grid = $('.grid').isotope({
itemSelector: '.grid-item',
percentPosition: true,
masonry: {
// use outer width of grid-sizer for columnWidth
columnWidth: '.grid-item',
}
});
//for menu active class
$('.portfolio-menu button').on('click', function(event) {
$(this).siblings('.active').removeClass('active');
$(this).addClass('active');
event.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment