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