๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

25-03-07

๐Ÿ“Œ Daily Reportโ€‹

https://github.com/ssginc-be/DOKI/issues/43


๐Ÿ“Œ ํ”„๋กœ์ ํŠธ ์ƒํ™ฉโ€‹

๋‚˜๋Š” ๋Œ€์ฒด ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ์ž์ธ๊ฐ€ ํผ๋ธ”๋ฆฌ์…”์ธ๊ฐ€


๐Ÿ“Œ forEach๋ฅผ ๋ชป์“ฐ๋Š” ์œ ์‚ฌ ๋ฐฐ์—ดโ€‹

getElementsByClassName์œผ๋กœ ๊ฐ€์ ธ์˜จ ๊ฐ์ฒด์— ์™œ forEach๊ฐ€ ์•ˆ๋จนํžˆ๋‚˜ ํ–ˆ๋”๋‹ˆ,

๋ฐ˜ํ™˜ ํƒ€์ž…์ด HTMLCollection์ด์—ˆ๋‹ค. ์Šฌํ”„๊ฒŒ๋„ ์ด๋Ÿฌํ•œ ์งญ ๋ฐฐ์—ด์€ forEach๊ฐ€ ์—†๋‹ค๊ณ  ํ•œ๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์€ Array.from()์„ ์ด์šฉํ•ด์„œ ๋ฐฐ์—ด๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด ๋œ๋‹ค.

admin_store_registration.js
function setMethod(event) {
const selectedButton = event;
console.log(event);
// ๋ฒ„ํŠผ ์Šคํƒ€์ผ ๋ณ€๊ฒฝ
const methodButtons = document.getElementsByClassName('reserve-method-button');
methodButtons.forEach(btn => {
btn.classList.remove('active');
});
selectedButton.classList.add('active');

...
}

client_console