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
|
<script>
window.onload=function(){
document.getElementById("btn").onclick=function(){
//다큐멘트에, 가져온다 btn버튼 클릭했을때 = 기능실행
//1번째 방법
let a= document.frm.jumsu.value; //문자형
let a=parseInt(document.frm.jumsu.value); //숫자형
//2번째방법
let b= document.getElementById("jumsu").value; //문자형
let b=parseInt(document.getElementById("jumsu").value); //숫자형
console.log(b);
console.log(typeof b);
}
}
</script>
<form name="frm">
<label for="jumsu">점수</label>
<input type="text" name="jumsu" id="jumsu">
<br>
<input type="button" id="btn" value="결과보기">
</form>
|
cs |
반응형