๊ด€๋ฆฌ ๋ฉ”๋‰ด

axnuo

[ ํ˜ผ๊ณต๋‹จ / JS ] 6์ฃผ์ฐจ - Chapter 07~08 ๋ณธ๋ฌธ

JS/ํ˜ผ๊ณต๋‹จ

[ ํ˜ผ๊ณต๋‹จ / JS ] 6์ฃผ์ฐจ - Chapter 07~08

axnuo 2023. 8. 20. 21:11

๐Ÿ’ก ์ง„๋„ : Chapter 07 ~ 08

๐Ÿ’ก ๊ธฐ๋ณธ ๋ฏธ์…˜ : p.315์˜ <์ง์ ‘ ํ•ด๋ณด๋Š” ์†์ฝ”๋”ฉ>์„ ์‹คํ–‰ํ•œ ํ›„ ์ถœ๋ ฅ๋˜๋Š” ๊ณ ์–‘์ด ์ด๋ฏธ์ง€ ์บก์ฒ˜ํ•˜๊ธฐ

๐Ÿ’ก ์„ ํƒ ๋ฏธ์…˜ : p. 325 ๋ˆ„์  ์˜ˆ์ œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋ณธ์ธ์˜ ํ•  ์ผ ๋ชฉ๋ก ๋งŒ๋“ค์–ด ์บก์ฒ˜ํ•˜๊ธฐ

๊ธฐ๋ณธ ๋ฏธ์…˜


    document.addEventListener('DOMContentLoaded', () => {
        const rects = document.querySelectorAll('.rect')   //ํŠน์ • ํด๋ž˜์Šค๋กœ ์š”์†Œ ์„ ํƒ
    
        rects.forEach((rect, index) => {
            const width = (index + 1) * 100
            const src = `<a href=http://placekitten.com/$>http://placekitten.com/$</a>{width}/250`
            rect.setAttribute('src', src)	//rect.src = src๋กœ ์ค„์ผ ์ˆ˜ ์žˆ์Œ
        })
    })
   

์ฑ…์„ ๋†“๊ณ  ์™€์„œ ๐Ÿ˜ข ์ถ”ํ›„์— ๋‹ค์‹œ ๋ณด๊ณ  ์˜ฌ๋ฆด ์˜ˆ์ •์ด๋‹ค..!..