How to remove certain elements or elements with particluar class or ID in masonry?

StackOverflow https://stackoverflow.com/questions/21546675

  •  06-10-2022
  •  | 
  •  

문제

Using this syntax to load Masonry items:

var msnry = new Masonry( "#container-div",
{
    columnWidth: 300,
    gutter: 10,
    isFitWidth: true,
    isAnimates: true,
    itemSelector: '.items',
    animationOptions:
    {
        duration: 600
    }
});

On click of a button or link I need to remove some items with .sample or #sample and this syntax does not works.

msnry.remove('.sample');

How to resolve?

도움이 되었습니까?

해결책

To remove masonry boxes with particular selector use this,

var remove=$('.sample'); // Use your removal class or ID here
msnry.remove(remove); // Attempting removal of the occurrences
msnry.reloadItems(); // Reload the layout
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top