-
샘플코드computer/JQuery 2016. 5. 20. 17:29
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
<select name="job">
<option value="">직업선택</option>
<option value="학생">학생</option>
<option value="회사원" selected="selected">회사원</option>
<option value="기타">기타</option>
</select>
<input type="text"/>
<script>
$("job").change(function(){
var sOptionValue = $("select option:selected").text();
if (sOptionValue === '학생') {
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
$('input').val(today);
}
});
</script>
</body>
</html>
'computer > JQuery' 카테고리의 다른 글
jQuery append 예제, remove 예제 (0) 2014.05.25 jQuery fadeIn, fadeOut, fadeTo 예제 (0) 2014.05.24 location.href 와 location.replace() (1) 2014.05.20 JQuery selectbox Control 제어 (0) 2014.04.15