본문 바로가기

개인스터디

블로그// UI // 달력 날짜

https://zetawiki.com/wiki/JQuery_CDN,_%EC%B5%9C%EC%8B%A0_%EB%B2%84%EC%A0%84_%EC%82%AC%EC%9A%A9

 

jQuery CDN, 최신 버전 사용 - 제타위키

다음 문자열 포함...

zetawiki.com

 

 

<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>

<h1>Jquery-ui 달력</h1>
<h2>date picker</h2>

선택일:<input type="text" id="date">
<br><br>
<p>text박스를 선택하면, 달력이 표시됩니다</p>

연도:<input type="text" id="year"><br>
월:<input type="text" id="month"><br>
일:<input type="text" id="day"><br>
요일:<input type="text" id="week">

<script type="text/javascript">
$(function () {
	
	let week = ['일', '월', '화', '수', '목', '금', '토'];
	
	$("#date").datepicker({
		dateFormat: "yy/mm/dd",
		dayNamesMin: week,
		monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
		onSelect: function ( d ) {
		//	alert(d);	// 2020/07/17
			
			let arr = d.split('/');
			
			$("#year").val( arr[0].trim() );
			$("#month").val( arr[1] );
			$("#day").val( arr[2] );
			
			// 요일
			let weekday = new Date( $("#date").datepicker({ dateFormat:"yy/mm/dd"}).val() );
		//	alert(weekday.getDay());
			
			$("#week").val( week[ weekday.getDay() ] );
		}
	});
});
</script>

'개인스터디' 카테고리의 다른 글

톰캣 한글깨짐 설정  (0) 2020.07.20
블로그// Slider을 이용한 투명도 조절 // 슬라이더  (0) 2020.07.17
블로그 // ui 소스 사이트  (0) 2020.07.17
블로그// 우편번호  (0) 2020.07.17
블로그1//레이아웃  (0) 2020.07.14