Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Pipelining
- Algorithm
- DS
- php
- instruction
- javascript
- github
- DB
- data structure
- architecture
- MIPS
- react
- DATAPATH
- web
- computer
- MacOS
- while
- python
- function
- DoM
- system
- CSS
- XML
- for
- Class
- control
- mysql
- Linux
- Java
- html
Archives
- Today
- Total
YYYEJI
[React] event.target.value 란? 본문
728x90
event.target.value가 무엇인지 알아보기 위해 아래 코드를 살펴보겠습니다.
tag에 onChange 이벤트를 설정해줍니다.
const onChange1 = (event) => {
console.log(event);
};
input tag도 만들어줍니다.
<input onChange={onChange1}/>
input에 입력 값이 들어오면 onChange1가 실행되면서 event 객체를 반환합니다.
event 객체는 아래와 같이 생겼습니다.
콘솔(console)에 event.target을 출력하면 event 객체의 target만 불러와서 출력해 줍니다.
const onChange1 = (event) => {
console.log(event.target);
};
콘솔(console)에 event.target.value를 출력하면 event 객체의 target에서 value만 출력해 줍니다.
const onChange1 = (event) => {
console.log(event.target.value);
};
사용자가(user)가 "1"을 입력하면
input의 value가 "1"로 바뀌면서 "1"을 출력하게 되는거죠.
◡̈
'Web Application Server (WAS)' 카테고리의 다른 글
[React] 리액트(React)에서 이미지 넣기 (0) | 2023.01.10 |
---|---|
[React] JSX expressions must have one parent element 에러 (0) | 2023.01.10 |
[React] useState() 함수 (0) | 2023.01.06 |
[React] 화살표 함수(Arrow Function) 만들기 (0) | 2023.01.06 |
[React] 리액트(React)에서 동영상 업로드하기 (0) | 2023.01.06 |