관리 메뉴

Jerry

[리뉴얼] 렛츠기릿 자바스크립트 #4 본문

Front/JavaScript

[리뉴얼] 렛츠기릿 자바스크립트 #4

juicyjerry 2022. 1. 6. 23:25
반응형

기본적으로 태그 내부의 값을 선택할 때는 textContent를 사용하는 게 맞지만, 입력 태그만 value를 사용합니다. input은 대표적인 입력 태그입니다. 다른 입력 태그로는 select와 textarea가 있습니다.
입력태그.value // 입력창의 값을 가져옴
입력태그.value = 값 // 입력창에 값을 넣음
입력태그.focus() // 입력창을 하이라이트


 다음 태그들의 내부 값을 가져올 때 둘 중 어떤 속성을 사용해야 하는지 표시해 보세요.

① input (value / textContent)
=> input.value

https://www.w3schools.com/tags/att_input_value.asp

 

HTML input value Attribute

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

 

 

② button (value / textContent)
=> button.textContent

https://www.w3schools.com/jsref/prop_node_textcontent.asp

 

HTML DOM textContent Property

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

 

 

 

 

③ select (value / textContent)
=> select.value

https://www.w3schools.com/jsref/prop_select_value.asp

 

HTML DOM Select value Property

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

 

 

 

 

④ div (value / textContent)
=> div.textContent

https://www.w3schools.com/jsref/prop_node_textcontent.asp

 

HTML DOM textContent Property

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

 

 

 

 

 

 

 

⑤ textarea (value / textContent)
=> textarea.value

https://www.w3schools.com/jsref/prop_textarea_value.asp

 

HTML DOM Textarea value Property

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

 

 

 

 

 

⑥ span (value / textContent)
=> span.textContent
https://www.javascripttutorial.net/javascript-dom/javascript-textcontent/

 

 

 

 

 

반응형