[javascript - (30) ] input type 동적으로 변경하기
<input type="button" name="test" value=100 />
<script>
var test = document.getElementsByName("test")[0]; test.setAttribute('type', 'hidden');
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
코드정리
<!DOCTYPE html>
<html>
<body>
<input value="OK">
<p>Click the button below to change the input field to an input button.</p>
<button onclick="myFunction()">Try it</button>
<p>Internet Explorer 8 and earlier does not support the setAttribute method.</p>
<script>
function myFunction() {
document.getElementsByTagName("INPUT")[0].setAttribute("type", "button");
}
</script>
</body>
</html>
|
실행 보기
https://www.w3schools.com/code/tryit.asp?filename=GF6OYWHQVMS5
'◽ HTML & CSS & JS, jQuery' 카테고리의 다른 글
[CSS] 모서리 둥글게 (0) | 2020.11.06 |
---|---|
[CSS] 모달창 화면 가운데로 위치 시키기 (0) | 2020.10.12 |
[javascript - (31) ] 테이블 헤더를 제외한 나머지 tr 지우기 (0) | 2020.05.27 |
[JavaScript - (29) ] encodeURI() : url로 서블릿에 파라미터 값 (한글) 넘길 시 (0) | 2020.05.23 |
null과 undefined (0) | 2020.04.20 |
[JavaScript - 기능 - (9) ] .unbind('click') : 이전에 넣은 이벤트 빼기 (0) | 2020.04.13 |
[JavaScript - 기능 - (10) ] 스트링값을 숫자로 바꾸기. (0) | 2020.04.02 |