jQuery
js를 미디어쿼리처럼 사용하기 (matchMedia)
Kale_coding
2023. 8. 21. 12:52
$(function(){
fn_widthResize();
})
function fn_widthResize() {
if (window.matchMedia('(max-width: 1024px)').matches) {
// 태블릿
$('.branch').off().click(function() {
$('.branch > div').css({ height: "auto" });
$('.branch > div').slideToggle();
$('.lang > ul').slideUp();
$('.remote').toggleClass('hide');
});
$('.lang').off().click(function() {
$('.lang > ul').slideToggle();
$('.branch > div').slideUp();
});
} else {
// PC
$('.branch').off().hover(function() {
$(this).children('div').stop().slideDown();
}, function() {
$(this).children('div').stop().slideUp();
});
$('.lang').off().hover(function() {
$(this).children('ul').stop().slideDown();
}, function() {
$(this).children('ul').stop().slideUp();
});
};
};
참고사이트