Javascript
Javascript - input value 가져오기
정리하고기록하자
2021. 10. 5. 16:31
반응형
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
function inputValueChange(){
var inputValue = document.getElementById('inputValue').value;
console.log(inputValue)
}
</script>
<input type="text" name="inputValue" id="inputValue" onchange="inputValueChange()" >
</body>
</html>
<body> 태그 안에 <input> 태그를 추가 하고 onchange 이벤트를 추가 했다.
- 위에 html를 Open in Brower 를 했을 때 ( 저는 Sublime Text 를 사용 합니다. )
<input>에 입력할 사항을 입력 했을 때
이렇게 <input> 태그에 입력한 value 값을 가져온다.
반응형