티스토리 뷰
HTML
<ul class="box-list n3 more-list js-more-list">
<li>more list 1</li>
<li>more list 2</li>
<li>more list 3</li>
<li>more list 4</li>
<li>more list 5</li>
<li>more list 6</li>
</ul>
<a href="#n" class="btn-more js-btn-more">MORE</a>
CSS
.box-list{
width: 100%;
}
.box-list:after{
display: block;
content: '';
clear: both;
}
.box-list > li{
float: left;
margin-left: 20px;
margin-top: 20px;
border: 1px solid #e8e9ee;
}
.box-list.n3{
margin-top: -20px;
}
.box-list.n3 > li{
width: calc((100% - 41px)/3);
}
.box-list.n3 > li:nth-child(3n+1){
margin-left: 0;
}
.more-list > li{
position: relative;
height: 390px;
padding: 70px 50px 50px;
-webkit-transition: 0.3s ease;
transition: 0.3s ease;
}
jQuery
if(wWidth < 769){
loadMore(3);
}else{
loadMore(9);
}
function loadMore(int){
$('.js-btn-more').hide();
if($('.js-more-list > li').length > int){
$('.js-btn-more').show();
$('.js-more-list > li').hide();
$('.js-more-list > li:first-child ~ li:nth-child(' + int + ')').show();
}
$('.js-more-list > li').slice(0, int).show();
$('.js-btn-more').on('click',function(e){
e.preventDefault();
if(!$('.js-more-list > li:hidden').length == 0){
$('.js-more-list > li:hidden').slice(0, int).show();
}else{
alert('내역이 없습니다.');
$('.js-btn-more').hide();
}
});
}
'WebPublisher > JavaScript & jQuery' 카테고리의 다른 글
[jQuery] top btn 탑버튼 만들기 (0) | 2022.12.20 |
---|---|
[javaScript] daterangepicker (0) | 2022.11.11 |
[jQuery] split 활용해 한 페이지에서 url 다르게 tab 링크 설정 (0) | 2022.08.18 |
[jQuery] 배너 sticky 이벤트 (0) | 2022.08.17 |
[javaScript] 이미지맵 반응형으로 적용 (rwdImageMaps) (0) | 2022.08.01 |
공지사항