isotope 필터 기능 질문드립니다.
조회수 377회
이렇게 필터를 만들었습니다. 현재는 클릭할 때만 작동이 되는데 처음 화면이 로드 될 때 class에 selected값이 있는 항목을 보여주고 싶은데 가능한가요?
<ul id="filter-buttons">
<li><a href="#" data-filter="food" class="selected">식품</a></li>
<li><a href="#" data-filter="kids" >KIDS</a></li>
<li><a href="#" data-filter="goods" >굿즈</a></li>
<li><a href="#" data-filter="love" >반려동물</a></li>
</ul>
<script>
var posts = $('.post');
posts.hide()
$('#filter-buttons li a').click(function(){
var customType = $(this).data('filter');
posts
.hide()
.filter(function(){
return $(this).data('cat') === customType;
})
.show();
})
</script>
댓글 입력