본문 바로가기
javascript

window width 따라 이벤트 발생시키기

by 바나냥 2020. 4. 3.
<div id="slider-pc">
	<ul class="indexSlider">
	     <li class="visual_01"></li>
	</ul>
</div>
	            
<!-- mobile slider -->
<div id="slider-mobile">
	<div class="indexSlider">
	     <img src="/VillaDeHotelAlliance_common/images/homepage/KOR/index/main_visual_01_m.jpg" alt="visual" />
	</div>
</div>

function setType(){
	if($(window).width() >= 720){
		$('#slider-pc').show();
		$('#slider-mobile').hide();
   }else{
	   $('#slider-mobile').show();
	   $('#slider-pc').hide();
   }
}

setType();

$(window).on("orientationchange load resize", function () {
	setType();
});

댓글