문의드립니다. 채택완료
아래는 첨부파일을 등록하면 뷰화면에서 왼쪽으로 이미지가 슬라이드 하는 소스입니다. 첨부파일이 총 10개까지 등록이 가능한데, 아래소스 중 7,8,9,10번째의 첨부파일을 등록하지 않으면 해당 div가 보이지 않게 하려는데 아래 소스로 테스트 하면 7,8,9,10번째에 빈div가 보이네요. 어떻게 해야 할까요?
$( document ).ready( function() {
$( '.swiper .swiper-wrapper .swiper-slide:empty' ).css("display", "none");
} );
답변 3개
다음 코드가 도움이 될지 모르겠습니다.
</p>
<p><script></p>
<p>// $( document ).ready( function() {</p>
<p>// $( '.swiper .swiper-wrapper .swiper-slide:empty' ).css("display", "none");</p>
<p>// } );</p>
<p></script></p>
<p> </p>
<p><div class="swiper mySwiper"></p>
<p> <div class="swiper-wrapper"></p>
<p> <?php
for ($i = 0; $i < 10; $i++) {
if(empty($view['file'][$i]['path']) == false && empty($view['file'][$i]['file']) == false) {
$imgsrc = $view['file'][$i]['path'].'/'.$view['file'][$i]['file'];
?>
<div class="swiper-slide"><img src="<?php echo $imgsrc; ?>"></div>
<?php
}
}
?></p>
<p> </div></p>
<p> </p>
<p> <div class="swiper-button-next"></div></p>
<p> <div class="swiper-button-prev"></div></p>
<p> </p>
<p> </div></p>
<p>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
<div class="swiper-slide"><?php if($view['file'][9]['path']) echo '<img src="'.$view['file'][9]['path'].'/'.$view['file'][9]['file'].'">';?></div>
// if($view['file'][9]['path']) 해당 조건을 div 밖으로 이동하세요.</p>
<p> </p>
<p>
<?php if($view['file'][9]['file']){ ?>
<div class="swiper-slide"><?php echo '<img src="'.$view['file'][9]['path'].'/'.$view['file'][9]['file'].'">';?></div>
<? } ?>
답변에 대한 댓글 1개
도움주셔서 감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
</p>
<p><script></p>
<pre>
$( document ).ready( function() {
$( '.swiper .swiper-wrapper .swiper-slide' ).each(function() {
if ($(this).find('img').length == 0) {
$(this).css("display", "none");
}
});
} );</pre>
<p></script></p>
<p>
답변에 대한 댓글 4개
$( '.swiper .swiper-wrapper .swiper-slide' ).each(function() {
if ($(this).find('img').attr('src') == "") {
$(this).hide();
}
});
} );
또는
$( document ).ready( function() {
$( '.swiper .swiper-wrapper .swiper-slide' ).each(function() {
if ($(this).find('img').attr('src') == "/") {
$(this).hide();
}
});
} );
로 바꿔보세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
하지만 이 코드가 제일 깔끔하군요.
감사합니다.