// 좌측 사이드 메뉴 접기/펴기 // var sideBtn = $(".side-nav__fold"); var header = $(".header"); var content = $(".content"); var sideNav = $(".side-nav"); var pageTitle = $(".page-title"); sideBtn.click(function () { $(this).toggleClass("closed"); header.toggleClass("closed"); content.toggleClass("closed"); sideNav.toggleClass("closed"); pageTitle.toggleClass("closed"); }); var media = window.matchMedia("(max-width: 1450px)"); function handleTabletChange(e) { if (e.matches) { $(".side-nav__fold").addClass("closed"); $(".header").addClass("closed"); $(".content").addClass("closed"); $(".side-nav").addClass("closed"); } else { $(".side-nav__fold").removeClass("closed"); $(".header").removeClass("closed"); $(".content").removeClass("closed"); $(".side-nav").removeClass("closed"); } } media.addEventListener("change", handleTabletChange); handleTabletChange(media); // 좌측 사이드메뉴 내부 메뉴 접기/펴기 // var depth2Btn = $(".depth2 > .has-sub"); var depth3 = $(".depth3"); depth2Btn.each(function () { $(this).find(".depth3").hide(); if ($(this).hasClass("opened")) { $(this).find(".depth3").show(); } }); depth2Btn.click(function () { // find depth2Btn but not this var otherBtn = depth2Btn.not(this); otherBtn.removeClass("opened"); otherBtn.find(".depth3").slideUp(300); $(this).toggleClass("opened"); $(this).find(".depth3").slideToggle(300); }); // 커스텀 셀렉트박스 // if ($(".select-box > select").length > 0) { $(".select-box > select").niceSelect(); } // 데이트 피커 // $(".datepicker").each(function () { $(this).datepicker({ dateFormat: "yy-mm-dd", prevText: "이전 달", nextText: "다음 달", changeMonth: "true", changeYear: "true", dayNames: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"], dayNamesMin: ["일", "월", "화", "수", "목", "금", "토"], monthNames: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월", ], monthNamesShort: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월", ], showMonthAfterYear: true, yearSuffix: "년", firstDay: 0/*, maxDate: 0, // 오늘로부터 1년 전까지의 날짜까지 선택 가능 beforeShowDay: function (date) { // 오늘로부터 1년 전까지의 날짜를 비활성화 let currentDate = new Date(); currentDate.setDate(currentDate.getDate() - 366); return [date.getTime() > currentDate.getTime() - 1, ""]; },*/ }); }); // 기간 선택 탭버튼 // 240123 Enter키 입력 시, 버그 수정 // var dateRangeBtn = $(".dateRange-btn"); dateRangeBtn.click(function (e) { if (e.detail === 0) { return; } e.preventDefault(); var otherBtn = $(this).siblings(); otherBtn.removeClass("selected"); $(this).addClass("selected"); }); // 숫자 텍스트 인풋 클릭 시 기본값 0 없어짐 // var numberInput = $(".input-text.number"); numberInput.click(function () { if ($(this).val() == 0) { $(this).val(""); } }); numberInput.blur(function () { if ($(this).val() == "") { $(this).val(0); } }); // "상세검색" 버튼 클릭 시 "search-hide" 보이기/숨기기 // var searchHide = $(".search-hide"); var searchBtn = $(".btn.search-detail"); searchBtn.click(function (e) { e.preventDefault(); if (searchHide.css("display") == "none") { searchHide.css("display", ""); } else { searchHide.css("display", "none"); } searchBtn.toggleClass("opened"); }); // "search-hide" 가 숨겨지있지 않을때 "상세검색" 버튼에 "opened" 클래스 추가 // if (!searchHide.eq(0).attr("style")) { searchBtn.addClass("opened"); } // 스크롤 시 헤더, 사이드메뉴 고정 // 231204 탭메뉴 고정 추가 var headerHeight = 110; var headerGap = headerHeight - 18; $(window).scroll(function () { var scrollTop = $(window).scrollTop(); var firstElement = $(".page-title").next(); if (firstElement.hasClass("content-tab__fixed")) { firstElement = firstElement.next(); headerGap = headerHeight; } if (scrollTop > headerHeight) { firstElement.css("margin-top", headerGap + "px"); $(".page-title").addClass("fixed"); $(".side-nav").addClass("fixed"); $(".content-tab__fixed").addClass("fixed"); } else { firstElement.css("margin-top", ""); $(".page-title").removeClass("fixed"); $(".side-nav").removeClass("fixed"); $(".content-tab__fixed").removeClass("fixed"); } }); // 체크시 테이블 행 배경색 변경 // var trColorCheck = $(".tr-color-check > input"); trColorCheck.click(function () { var tr = $(this).closest("tr"); if ($(this).prop("checked")) { tr.addClass("checked"); } else { tr.removeClass("checked"); } }); // 쿠폰 할인금액/할인율 선택 // var couponDiscountSelect = $(".coupon-discount-select"); var couponDiscountWon = $(".coupon-discount-won"); var couponDiscountPercent = $(".coupon-discount-percent"); $(document).ready(function () { couponDiscountSelectChange(); }); couponDiscountSelect.change(function () { couponDiscountSelectChange(); }); function couponDiscountSelectChange() { if (couponDiscountSelect.val() == "won") { couponDiscountWon.show(); couponDiscountPercent.hide(); } else { couponDiscountWon.hide(); couponDiscountPercent.show(); } } // 탭 버튼 // var contentTabBtn = $(".content-tab__btn"); var contentTabContent = $(".content-tab__content"); contentTabBtn.click(function (e) { e.preventDefault(); var index = $(this).index(); contentTabBtn.removeClass("active"); contentTabContent.removeClass("active"); $(this).addClass("active"); contentTabContent.eq(index).addClass("active"); }); $(document).ready(function () { // $(".content-tab__btn").eq(0).trigger("click"); }); // 툴팁(호버시 툴팁 노출) var tooltipElem; document.onmouseover = function (event) { var evt = event || window.event; var target = evt.target || evt.srcElement; var tooltipHtml = target.getAttribute("data-tooltip"); if (!tooltipHtml) return; tooltipElem = document.createElement("div"); tooltipElem.className = "tooltip"; tooltipElem.innerHTML = tooltipHtml; document.body.appendChild(tooltipElem); var coords = target.getBoundingClientRect(); var left = coords.left + (target.offsetWidth - tooltipElem.offsetWidth) / 2; if (left <= 14) left = 14; var top = coords.top - tooltipElem.offsetHeight - 5; if (top < 0) { top = coords.top + target.offsetHeight + 5; } tooltipElem.style.left = left + "px"; tooltipElem.style.top = top + "px"; }; document.onmouseout = function (event) { if (tooltipElem) { tooltipElem.parentNode.removeChild(tooltipElem); tooltipElem = null; } }; // var sumAreaContent = $(".sum-area__content"); var sumAreaBtn = $(".sum-area__title > button"); sumAreaBtn.click(function (e) { e.preventDefault(); $(this).closest(".sum-area__item").find(sumAreaContent).toggleClass("opened"); $(this).toggleClass("opened"); }); // 위로가기 버튼 var scrollToTop = $(".scroll-to-top"); var handleScroll = function () { var scrollTop = $(window).scrollTop(); if (scrollTop > 100) { scrollToTop.addClass("show"); } else { scrollToTop.removeClass("show"); } }; var debounce = function (func, delay) { var timer; return function () { var context = this, args = arguments; clearTimeout(timer); timer = setTimeout(function () { func.apply(context, args); }, delay); }; }; $(window).scroll(debounce(handleScroll, 50)); scrollToTop.click(function () { $("html, body").animate({ scrollTop: 0 }, 400); }); // 컨텐츠 접기/펴기 // var foldBtn = $(".content-fold__btn"); var contentFold = $(".content-section.content-fold"); foldBtn.click(function (e) { var innerContent = $(this).closest(contentFold).find(".content-fold__content"); e.preventDefault(); if (innerContent.css("display") == "none") { innerContent.show(); } else { innerContent.hide(); } $(this).toggleClass("opened"); }); // 스크롤 탭 버튼(상품 등록 페이지) // var contentTabScrollBtn = $(".content-tab__scroll-btn"); var contentTabScrollContent = $(".content-scroll-detect"); $(document).ready(function () { contentTabScrollBtn.eq(0).addClass("active"); }); contentTabScrollBtn.click(function (e) { e.preventDefault(); var index = $(this).index(); contentTabScrollBtn.removeClass("active"); $(this).addClass("active"); $("html, body").animate( { scrollTop: contentTabScrollContent.eq(index).offset().top - 128, }, 0 ); }); function handleTabScroll() { var scrollTop = $(window).scrollTop(); contentTabScrollContent.each(function () { var index = contentTabScrollContent.index(this); if (scrollTop >= $(this).offset().top - 260) { contentTabScrollBtn.removeClass("active"); contentTabScrollBtn.eq(index).addClass("active"); } if (scrollTop < 100) { contentTabScrollBtn.removeClass("active"); contentTabScrollBtn.eq(0).addClass("active"); } }); } $(window).scroll(debounce(handleTabScroll, 20)); // 타임 피커 // if ($(".bs-timepicker").length > 0) { $(".bs-timepicker").timepicker(); } // 셀렉트 선택 시 링크 이동 // $(".select-link").on("change", function () { var url = $(this).val(); if (url) { window.open(url, "_self"); $(".nice-select li").removeClass("selected"); $(".nice-select .current").text("주요 게시판"); } return false; }); //인풋 텍스트 글자수 제한 // var wordLimitInput = $(".word-limit-input > input"); var wordLimitNumbers = $(".word-limit-input__data"); var wordLimitMax = $(".word-limit-input__data .max-words"); var wordLimitCurrent = $(".word-limit-input__data .current-words"); wordLimitMax.each(function () { $(this).text($(this).closest(".word-limit-input").find("input").attr("maxlength")); }); wordLimitCurrent.each(function () { $(this).text($(this).closest(".word-limit-input").find("input").val().length); }); wordLimitInput.keyup(function () { var current = $(this).val().length; $(this).closest(".word-limit-input").find(wordLimitCurrent).text(current); }); // 테이블 열 순서 바꾸기 // $(document).ready(function () { if ($(".table.draggable").length > 0) { $(".table.draggable").tableDnD({ onDragClass: "dragging", }); } }); // 인풋 텍스트 숫자만 입력, 3자리마다 콤마 // $(".input-text.number").on("input", function () { var input = $(this).val(); $(this).val(input.replace(/[^0-9]/g, "").replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")); }); // 미니 인포 버튼 var miniInfoBtn = $(".mini-info-btn"); var miniInfoContent = $(".mini-info-content"); var miniInfoCloseBtn = $(".mini-info-content__close"); miniInfoContent.hide(); miniInfoBtn.click(function (e) { e.preventDefault(); // data-info 속성값 가져오기 var info = $(this).attr("data-info"); // id가 info인 요소에 miniInfoBtn의 위치를 기준으로 miniInfoContent를 노출 $("#" + info).css({ top: $(this).offset().top, left: $(this).offset().left, }); if ($(this).offset().left > 1000) { $("#" + info).css({ left: $(this).offset().left - $("#" + info).width() - 10, }); } $("#" + info).show(); }); miniInfoCloseBtn.click(function (e) { e.preventDefault(); $(this).closest(".mini-info-content").hide(); }); // 상품 검색 - 상품선택 // var leftProductLists = $(".product-search-box > .table-wrapper.left tbody tr"); // leftProductLists.click(function () { // leftProductLists.removeClass("checked"); // $(this).addClass("checked"); // }); // 체크박스 전체 선택 // function checkAllCheckBoxes(checkAll, checkbox) { if (checkAll.prop("checked")) { checkbox.prop("checked", true); checkIfColorCheck(checkbox); } else { checkbox.prop("checked", false); checkIfColorCheck(checkbox); } } function checkIfColorCheck(checkbox) { checkbox.each(function () { if (!$(this).closest(".b-checkbox").hasClass("tr-color-check")) return; if ($(this).prop("checked")) { $(this).closest("tr").addClass("checked"); } else { $(this).closest("tr").removeClass("checked"); } }); } // 테이블 체크박스 전체 선택 var tableCheckAll = $(".table .check-all > input[type=checkbox]"); tableCheckAll.click(function () { var colIndex = $(this).closest("th").index(); var checkbox = $(this) .closest(".table") .find("tbody tr td:nth-child(" + (colIndex + 1) + ") input[type=checkbox]"); checkAllCheckBoxes($(this), checkbox); }); // multi-select 체크박스 전체 선택 var multiCheckAll = $(".multi-select .check-all > input[type=checkbox]"); multiCheckAll.click(function () { var checkbox = $(this).closest(".multi-select").find("input[type=checkbox]"); checkAllCheckBoxes($(this), checkbox); }); // 같은 컨테이너 안의 체크박스 전체 선택 var containerCheckAll = $(".b-checkbox-container .check-all > input[type=checkbox]"); containerCheckAll.click(function () { var checkbox = $(this).closest(".b-checkbox-container").find("input[type=checkbox]"); checkAllCheckBoxes($(this), checkbox); }); // Dropzone 파일업로드 if ($("#my-dropzone").length > 0) { Dropzone.autoDiscover = false; var myDropzone = new Dropzone("#my-dropzone", { url: "/file-upload", maxFilesize: 20, autoProcessQueue: false, addRemoveLinks: true, dictDefaultMessage: "클릭하거나 파일을 여기로 드래그하세요", dictRemoveFile: "삭제", dictCancelUpload: "취소", dictCancelUploadConfirmation: "업로드를 취소하시겠습니까?", dictInvalidFileType: "이 파일은 업로드할 수 없습니다.", dictFileTooBig: "파일이 너무 큽니다. ({{filesize}}MB). 최대 파일 크기: {{maxFilesize}}MB.", dictMaxFilesExceeded: "파일을 더 이상 추가할 수 없습니다.", dictResponseError: "서버에서 응답을 받지 못했습니다.", }); } //주요 게시판 보기 설정 // // 전체게시판 <-> 노출게시판 이동 var boardLeftSelect = $(".board-setting__left .board-setting__select"); var boardRightSelect = $(".board-setting__right .board-setting__select"); var boardToRightBtn = $(".board-setting__move-btn.right"); var boardToLeftBtn = $(".board-setting__move-btn.left"); boardToRightBtn.click(function (e) { e.preventDefault(); moveSelectedOptions(boardLeftSelect, boardRightSelect); }); boardToLeftBtn.click(function (e) { e.preventDefault(); moveSelectedOptions(boardRightSelect, boardLeftSelect); }); function moveSelectedOptions(from, to) { from.find("option:selected").each(function () { to.append($(this)); }); } // 노출게시판 순서 변경 var boardUpBtn = $(".board-setting__controls .btn.up"); var boardDownBtn = $(".board-setting__controls .btn.down"); var boardTopBtn = $(".board-setting__controls .btn.top"); var boardBottomBtn = $(".board-setting__controls .btn.bottom"); boardUpBtn.click(function (e) { e.preventDefault(); var selectElement = $(this) .closest(".board-setting__controls") .siblings(".board-setting__select"); if (selectElement.find("option:selected").index() == 0) return; selectElement.find("option:selected").each(function () { var current = $(this); current.insertBefore(current.prev()); }); }); boardDownBtn.click(function (e) { e.preventDefault(); var selectElement = $(this) .closest(".board-setting__controls") .siblings(".board-setting__select"); var selectedOptions = selectElement.find("option:selected"); $([...selectedOptions].reverse()).each(function () { var currentOption = $(this); var nextOption = currentOption.next("option:not(:selected)"); if (nextOption.length) { nextOption.after(currentOption); } }); }); boardTopBtn.click(function (e) { e.preventDefault(); var selectElement = $(this) .closest(".board-setting__controls") .siblings(".board-setting__select"); if (selectElement.find("option:selected").index() == 0) return; var selectedOptions = []; selectElement.find("option:selected").each(function () { selectedOptions.push($(this)); }); selectedOptions.reverse().forEach(function (option) { option.insertBefore(option.siblings().first()); }); }); boardBottomBtn.click(function (e) { e.preventDefault(); var selectElement = $(this) .closest(".board-setting__controls") .siblings(".board-setting__select"); if (selectElement.find("option:selected").index() == selectElement.find("option").length - 1) { return; } selectElement.find("option:selected").each(function () { var current = $(this); current.insertAfter(current.siblings().last()); }); }); //테이블 행 삭제 // var table = $(".table"); var tableDeleteBtn = $("tbody tr .circle-btn.delete"); table.on("click", ".circle-btn.delete", function (e) { e.preventDefault(); var tbody = $(this).closest("tbody"); var tr = $(this).closest("tr"); var th = $(this).closest("th"); var allHidden = true; tr.siblings().each(function () { if ($(this).css("display") !== "none") { allHidden = false; } }); if (th.attr("rowspan") > 1) { tr.next().remove(); th.attr("rowspan", th.attr("rowspan") - 1); } tr.remove(); if (tbody.children().length == 0 || allHidden) { tbody.append( "데이터가 없습니다." ); } }); // 인풋 텍스트 숫자만 입력, 3자리마다 콤마 // $(".input-text.time-number").on("input", function () { var input = $(this).val(); $(this).val(input.replace(/[^0-9]/g, "")); }); // 체크박스 선택 시, 테이블 행 숨기기/보이기 // var checkHide = $(".check-hide"); checkHide.hide(); var checkHideTrigger = $(".check-hide-trigger > input[type=checkbox]"); checkHideTrigger.click(function () { if ($(this).prop("checked")) { var checkHideId = $(this).attr("data-checkhide"); addRowspan($(this), parseInt($(this).attr("data-rowspan"))); $("#" + checkHideId).show(); } else { var checkHideId = $(this).attr("data-checkhide"); addRowspan($(this), parseInt($(this).attr("data-rowspan") - 1)); $("#" + checkHideId).hide(); } }); function addRowspan(check, number) { var rowspan = 1; if (number > 1) { rowspan = number; } check.closest("tr").find("th.add-rowspan").attr("rowspan", rowspan); } // 라디오 버튼 선택 시, 테이블 숨기기/보이기 // var radioTab = $(".radio-tab-content"); var radioTabTrigger = $(".radio-tab-trigger > .custom-radio > input[type=radio]"); radioTab.children().hide(); radioTab.each(function () { $(this).children().eq(0).show(); }); radioTabTrigger.click(function () { if (!$(this).prop("checked")) { return; } // data-radiotab 값과 id같아야함 var radioTabId = $(this).closest(".radio-tab-trigger").attr("data-radiotab"); var radioTab = $("#" + radioTabId); radioTab.children().hide(); // var index = $(this).closest(".custom-radio").index(); var index = $(this) .closest(".radio-tab-trigger") .find(".custom-radio") .index($(this).closest(".custom-radio")); radioTab.children().eq(index).show(); }); // 주문조회 상품 상세 접기/펴기 // var orderSectionDetail = $(".order-section__detail"); var orderSectionDetailTrigger = $(".order-section__detail-trigger"); orderSectionDetail.hide(); orderSectionDetailTrigger.click(function (e) { e.preventDefault(); $(this).closest("tr").next(".order-section__detail").toggle(); if ($(this).hasClass("opened")) { $(this).removeClass("opened"); } else { $(this).addClass("opened"); } }); // 호버시 박스 띄우기 // var hoverBoxTrigger = $(".hover-box-trigger"); var hoverBoxContent = $(".hover-box-content"); hoverBoxContent.hide(); hoverBoxTrigger.hover(function () { var index = $(this).attr("data-hoverbox"); var selectedHoverContent = $("#" + index); if ($(this).closest(".modal").length > 0) { selectedHoverContent.css({ zIndex: 200, }); } selectedHoverContent.show(); var left = $(this).offset().left; var top = $(this).offset().top; var width = $(this).width(); var height = $(this).height(); selectedHoverContent.css({ left: left + width + 10, top: top + height / 2 - selectedHoverContent.height() / 2, }); }); hoverBoxTrigger.mouseleave(function () { hoverBoxContent.hide(); }); // 주문조회 상품 상세 모두 접기/펴기 // var orderOpenAll = $(".order-open-all"); orderOpenAll.click(function (e) { e.preventDefault(); if ($(this).hasClass("opened")) { $(this).removeClass("opened"); $(this).closest("tr").nextUntil(".order-section__footer", ".order-section__detail").hide(); $(this) .closest("tr") .nextUntil(".order-section__footer") .find(".order-section__detail-trigger") .removeClass("opened"); $(this).text("모두열기"); } else { $(this).addClass("opened"); $(this).closest("tr").nextUntil(".order-section__footer", ".order-section__detail").show(); $(this) .closest("tr") .nextUntil(".order-section__footer") .find(".order-section__detail-trigger") .addClass("opened"); $(this).text("모두닫기"); } }); // 셀렉트 박스 선택 시, 컨텐츠 보이기/숨기기 // 240123 여러개인 경우도, 적용되게 수정 var selectShowTrigger = $(".select-show-trigger"); var selectShowContent = $(".select-show-content"); selectShowContent.hide(); selectShowTrigger.each(function () { $(this).siblings(".select-show-content").eq(0).show(); }); selectShowTrigger.find("select").change(function () { var value = $(this).val(); var currentContent = $(this).closest(".select-show-trigger").siblings(".select-show-content"); currentContent.each(function () { if (value == $(this).attr("id")) { $(this).show(); } else { $(this).hide(); } }); }); // 참여이벤트 셀렉트 선택 var eventTypeSelect = $("#event-type-select"); var eventTypeSelectContent = $(".event-type-select__content"); eventTypeSelectContent.hide(); eventTypeSelectContent.each(function () { if ($(this).attr("data-eventtype") == eventTypeSelect.val()) { $(this).show(); } }); eventTypeSelect.change(function () { var value = $(this).val(); eventTypeSelectContent.each(function () { if (value == $(this).attr("data-eventtype")) { $(this).show(); } else { $(this).hide(); } }); }); // 탭 ui var tabBox = $(".tab-box"); var tabBoxBtn = $(".tab-box__btn"); var tabBoxContentItems = $(".tab-box__content > *"); tabBoxContentItems.hide(); tabBox.each(function () { $(this).nextAll($(".tab-box__content")).eq(0).find(tabBoxContentItems).show(); }); tabBoxBtn.click(function (e) { e.preventDefault(); var index = $(this).index(); $(this).closest(tabBox).find(tabBoxBtn).removeClass("current"); $(this).addClass("current"); $(this).closest(tabBox).nextAll($(".tab-box__content")).find(tabBoxContentItems).hide(); $(this) .closest(tabBox) .nextAll($(".tab-box__content")) .eq(index) .find(tabBoxContentItems) .show(); }); // 쿠폰 정보 모달 (모달안에 모달) $("#coupon-info-pop-trigger").click(function (e) { $("#coupon-info-pop").modal({ closeExisting: false, }); }); // 상품 검색 // 왼쪽 영역 클릭 시 오른쪽으로 추가, 오른쪽 영역 더블클릭시 삭제 var productSearchLeftTable = $(".product-search-box > .table-wrapper.left >.table"); var productSearchRightTable = $(".product-search-box > .table-wrapper.right >.table"); var productSearchLeftRow = $(".product-search-box > .table-wrapper.left >.table > tbody > tr"); var productSearchRightRow = $(".product-search-box > .table-wrapper.right >.table > tbody > tr"); productSearchLeftRow.click(function (e) { var thisId = e.currentTarget.id; if (productSearchRightTable.find("#" + thisId).length > 0) { return; } $(this).removeClass("checked"); if (productSearchRightRow.length === 0) { productSearchRightTable.find("tbody > tr").remove(); } $(this).clone().appendTo(productSearchRightTable.find("tbody")); productSearchLeftRow.removeClass("checked"); $(this).addClass("checked"); productSearchLeftRow = $(".product-search-box > .table-wrapper.left >.table > tbody > tr"); productSearchRightRow = $(".product-search-box > .table-wrapper.right >.table > tbody > tr"); productSearchRightTable.tableDnDUpdate(); }); productSearchRightTable.on("dblclick", "tr", function (e) { e.preventDefault(); $(this).remove(); productSearchRightRow = $(".product-search-box > .table-wrapper.right >.table > tbody > tr"); productSearchRightTable.tableDnDUpdate(); if (productSearchRightRow.length === 0) { productSearchRightTable .find("tbody") .append( "선택된 상품이 없습니다." ); } }); // 모달 안에 모달 열었을 때, 기존 모달 닫히지 않게 하기(전역 적용) $.modal.defaults.closeExisting = false; // 모달 바깥영역 클릭 시 닫히지 않게 하기(전역 적용) $.modal.defaults.clickClose = false; //해당 클래스를 가진 요소 3자리 마다 콤마 $(".comma").each(function () { var text = $(this).text(); $(this).text(text.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, "$1,")); });