블로그 · 2023년 4월 27일 · 읽기 1분

날짜에 따라 구매 버튼 활성화

var applyBtnObj = [{ el: $('.socks .btn_area'), time: '2023-04-29T18:00:00', }, { el: $('.t_shirts .btn_area'), time: '2023-04-30T18:00:00', }, { el: $('.hoddies .btn_area'), time: '2023-04-30T18:00:00', } ]; var today = new Date().getTime(); // 테스트코드 /?date=2023-04-30T19:00:00 if (new URLSearchParams(location.search).get('date')) { today = new Date(new URLSearchParams(location.search).get('date')).getTime(); } // // 날짜에 따라 상품 구매버튼 활성화 for (let i in applyBtnObj) { if (today > new Date(applyBtnObj[i].time).getTime()) { applyBtnObj[i].el.removeClass('dimd'); applyBtnObj[i].el.find('img').attr("src", 'https://버튼이미지.webp' ); } }