最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In jQuery Isotope or Masonry, can I ignore an item? - Stack Overflow

programmeradmin1浏览0评论

I have this list of items I want to filter through:

<ul id="container">
    <li class="item filter">This is where I'd put my filters</li>
    <li class="item">Item 1</li>
    <li class="item">Item 2</li>
    <li class="item">Item 3</li>
</ul>

So then I want to execute it like so...

  $container.isotope({
    itemSelector : '.item'
  });

...but I want an option like ignore: '.filter'. Is something like that doable?

The whole goal is to put the filters inside the container, taking on the same styles and transitions.

I have this list of items I want to filter through:

<ul id="container">
    <li class="item filter">This is where I'd put my filters</li>
    <li class="item">Item 1</li>
    <li class="item">Item 2</li>
    <li class="item">Item 3</li>
</ul>

So then I want to execute it like so...

  $container.isotope({
    itemSelector : '.item'
  });

...but I want an option like ignore: '.filter'. Is something like that doable?

The whole goal is to put the filters inside the container, taking on the same styles and transitions.

Share Improve this question edited Oct 20, 2014 at 6:00 Sameera Thilakasiri 9,50810 gold badges53 silver badges87 bronze badges asked Oct 23, 2012 at 23:30 developdalydevelopdaly 1,3753 gold badges16 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7
$container.isotope({
    itemSelector : '.item:not(.filter)'
});

Simply use the :not() selector.

EDIT:

You suggest wanting to include it in the initial isotope selection, and for it to act as an item of the isotope, except not be filterable - at least this is how I am understanding you.
So to achieve this, keep your original:

$container.isotope({
    itemSelector : '.item'
});

And later, when you do your filters, simply always include , .filter
Example:

//Assume something got clicked, which had a data-filter attribute.
var filters = $(this).data('filter');
$container.isotope({
    filter: filters +', .filter'
});
发布评论

评论列表(0)

  1. 暂无评论