$.exists = function(selector) { return ($(selector).length > 0); } $(function () { /* 서브 모바일 메뉴 스타일 02에만 적용 */ if ($.exists("#sub_m_menu_style_02")) { var dep1MobileMenu = $(".sub-visual-txt-con").find('h2').text(); $(".location1").find(".cur-location").find("span").text(dep1MobileMenu) } // SUB MOBILE MENU $(".sub-top-menu-m").find(".dropdown-menu").click(function () { var $subMenuList = $(this).find(".dropdown-list"); if ($.exists("#sub_m_menu_style_02")) { $(".sub-top-menu-m").find(".dropdown-menu").removeClass("open") } if ($subMenuList.css("display") == "block") { $subMenuList.stop().slideUp(); $(this).removeClass("open") } else { $subMenuList.stop().slideDown(); $(this).addClass("open") } }) // PC :: 스타일 1,2와 3의 경우의 js 분리 if ($.exists("#sub_menu_style_03")) { var dep1CurrentMenu = $(".sub-top-menu .location1 > button > span").text(); var dep1ListMenu = $(".sub-top-menu .location1 .snb"); var currentUrlBefore = window.location.href; var currentUrl = $(currentUrlBefore.split('?')); /* 1차 메뉴 */ $(dep1ListMenu).find("li").each(function () { var indexMenu = $(this).find("a").text(); if (dep1CurrentMenu == indexMenu) { $(this).addClass("on") } }) /* 2차 메뉴 */ $(".sub-top-menu").find(".location2").find("li").each(function () { var urlSplitBefore = $(this).find("a").prop("href"); var urlSplit = $(urlSplitBefore.split('?')); if (urlSplit[0] == currentUrl[0]) { $(this).addClass("on") } }) } else { var currentUrlBefore = window.location.href; var currentUrl = $(currentUrlBefore.split('?')); $(".sub-top-menu").find("li").each(function () { var urlSplitBefore = $(this).find("a").prop("href"); var urlSplit = $(urlSplitBefore.split('?')); if (urlSplit[0] == currentUrl[0]) { $(this).addClass("on") } }) } // 게시판 버튼 if ($(".bbs-search-box").hasClass("iconUse")) { $(".est_btn_cell input").attr("src", "") var searchIcon = $(".cm_icon_search").prop("value") $(".est_btn_cell input").attr("value", searchIcon) $(".est_btn_cell input").attr("type", "submit") } })