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

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

  •  06-10-2022
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top