728x90

제이쿼리에서 지원해주는 기본 달력

페이지를 만들다 보면 날짜를 가져와야되는 경우가 많은데 이럴때 유용하게 쓸 수 있는 제이쿼리에서 지원해주는 달력을 알아 보겠습니다.

<!doctype html>
<html lang="kr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
 
 
</body>
</html>

 

이런식으로 소스를 넣으면 바로 달력을 이용할수 있어서 날짜를 가져올때 편하게 쓸 수 있으며, 링크 형식이라 라이브러리도 따로 필요없는 장점이 있습니다.

 

만약 포맷 방식을 바꾸고 싶다면

//"mm/dd/yy"
//"yy-mm-dd"
//"d M, y"
//"d MM, y"
//"DD, d MM, yy"
//"&apos;day&apos; d &apos;of&apos; MM &apos;in the year&apos; yy"
$( "#datepicker" ).datepicker( "option", "dateFormat","포맷형식");

이런식으로 추가해서 포맷형식을 바꿀 수 있습니다.

 

더 자세한 사항은 https://jqueryui.com/datepicker/#default 여기에서 참고하시면 됩니다.

반응형
SMALL

+ Recent posts