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
- 오라클
- 자바
- javaservlet
- JavaScript
- 연락처 프로그램
- css
- GUI
- list
- spring
- 설치
- 윈도우 #단축키
- 데이터베이스
- 파일 입출력
- 다형성
- 연산자
- Java
- property
- 상속
- function
- Event
- 코틀린#클래스#상속
- File 클래스
- jsp
- Method
- jQuery
- String
- html
- array
- kotlin #return #jump
- springframework
Archives
- Today
- Total
Binary World
자바스크립트 이벤트(Event) 03 본문
<자바스크립트 이벤트>
<29_event3.html>
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JavaScript</title> </head> <body> <h1>HTML event</h1> <input type="text" name="userid" id="userid" autofocus onfocus="changeBgColor(this)" onblur="resetBgColor(this)" onchange="toUpper(this)"/> <br/> <select onchange="select(this)"> <option value="1">빨강</option> <option value="2">녹색</option> <option value="3">파랑</option> </select> <script type="text/javascript"> // onfocus: 포커스를 받았을 때 // -> 입력상자(input)의 배경색을 바꿈 function changeBgColor(input){ input.style.backgroundColor = 'lightyellow'; } // onblur: 포커스를 잃었을 때 // -> 입력상자(input)의 배경색을 원래대로 바꿈 function resetBgColor(input){ input.style.backgroundColor = 'white'; } // onchange: 입력 내용이 바꼈을 때(입력 후 엔터나 탭 키 입력했을 때) // -> 입력 내용을 모두 대문자로 바꿈 function toUpper(input){ input.value = input.value.toUpperCase(); } function select(sel) { var color = sel.value; // document.body.style.backgroundColor = color; switch(color){ case '1': document.body.style.backgroundColor = 'red'; break; case '2': document.body.style.backgroundColor = 'green'; break; case '3': document.body.style.backgroundColor = 'blue'; break; default: document.body.style.backgroundColor = 'white'; } } </script> </body> </html> | cs |
<출력화면>
- 실행 전
- 실행 후
'개발자의 길 > Javascript' 카테고리의 다른 글
자바스크립트 이벤트(Event) 05 (0) | 2017.04.07 |
---|---|
자바스크립트 이벤트(Event) 04 (0) | 2017.04.07 |
자바스크립트 이벤트(Event) 02 (0) | 2017.04.07 |
자바스크립트 이벤트(Event) 01 (0) | 2017.04.07 |
자바스크립트 요소(Element) 찾기 (1) | 2017.04.06 |
Comments