JS14 HTML과 연동시키기 1. 파일명.js 생성 2. html 파일 맨 마지막에 아래 태그 넣기 3. alert 등으로 연결 잘 되어있는지 확인 2022. 5. 26. 랜덤숫자 구하기 Math.floor(Math.random() * (maximum – minimum + 1)) + minimum 예) 1포함 6까지 랜덤으로 숫자를 구하고 싶다. Math.floor(Math.random() * 6) + 1 2022. 5. 26. 태그의 특정속성만 골라서 업데이트 _ attributes Google a태그에 있는 속성을 모두 보고싶을때 document.querySelector('a').attributes a태그에 있는 특정속성을 보고싶을때 document.querySelector('a').getAttribute('href') 태그이름 속성이름 a태그에 있는 특정속성을 바꾸고 싶을때 document.querySelector('a').setAttributes('href','https://www.naver.com') 태그이름 속성이름 바꾸고자하는 내용 2022. 5. 25. innerHTML VS textContent HELLO WORLD 이라는 HTML이 있을때, ✔️ document.querySelector('h1').innerHTML ▶ HELLO WORLD ✔️ document.querySelector('h1').textContent ▶ HELLO WORLD 2022. 5. 25. 이전 1 2 3 4 다음