嗨我想在我的页面加载时只显示一个过滤器(.one)。 无法弄清楚如何做到这一点 - 对于js来说不是很聪明:(
我的HTML: 类=" ISOTOP滤波器" ID ="过滤器"
<button type="button" class="btn btn-isotop is-checked" data-filter="*">All</button>
<button type="button" class="btn btn-isotop" data-filter=".one">1</button>
<button type="button" class="btn btn-isotop" data-filter=".two">2</button>
<button type="button" class="btn btn-isotop" data-filter=".three">3y</button>
</div>
我的js看起来像这样:
$(window).load(function(){
// Initialize Isotope
var $container = $('.isotope').isotope({
itemSelector: 'li',
//percentPosition: true
});
// Bind filter button click
$('#filters').on( 'click', 'button', function(){
var filterValue = $( this ).attr('data-filter');
$container.isotope({ filter: filterValue });
});
// change is-checked class on buttons
$('.button-group').each( function( i, buttonGroup ){
var $buttonGroup = $( buttonGroup );
$buttonGroup.on( 'click', 'button', function(){
$buttonGroup.find('.is-checked').removeClass('is-checked');
$( this ).addClass('is-checked');
});
});
//Hover Direction
$(function() {
$('#da-thumbs').find('> li').each(function () {
$(this).hoverdir({
hoverDelay : 75
});
});
});
});