반응형
Notice
Recent Posts
Recent Comments
Link
taenyLog
Document : 속성 Attributes 본문
반응형
document.querySelector(' ')
document.querySelector(' # ') --> id검색으로 더 세세한 작업 가능
const firstLink = document.querySelector('a')
firstLink.href ---> 직접 엑세스하는 경우에는 자바스크립트를 거친다. 따라서 아래의 결과값과 달리 앞에 file이 불는다.
> "file:///wiki/List_of_chicken_breeds"
firstLink.getAttribute('href' ) ---> getAttribute를 사용하면 HTML에서 직접 가져오게된다.
> "/wiki/List_of_chicken_breeds"
setAttribute( name, value)
const button = document.querySelector("button");
button.setAttribute("name", "helloButton");
name의 속성값을 helloButton으로 변경한다.
반응형
'Web' 카테고리의 다른 글
html에서의 각 글자 색 변경 (feat.js) (1) | 2023.09.27 |
---|---|
Document : innerHTML, textContent, innerText (0) | 2023.09.27 |
Document : querySelector , querySelectorAll (0) | 2023.09.27 |
Document: getElementById, getElementsByTagName, getElementsByClassName (0) | 2023.09.27 |
DOM(Document Object Model) (0) | 2023.09.27 |