我使用這個JavaScript代碼來使用hijri日期選擇器,但是當我打開datepicker並且比點擊div或身體上我的datepiker沒有關閉。當我點擊邊時,任何人都可以幫助關閉日期選擇器。我需要更正此代碼並隱藏日曆,當我點擊日曆或正文外部時。Datepicker不關閉點擊外部
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<title>Health Athority</title>
\t <link rel="stylesheet" href="https://ZulNs.github.io/libs/calendar.css"/>
\t <script type="text/javascript" src="https://ZulNs.github.io/libs/hijri-date.js"></script>
\t <script type="text/javascript" src="js_clander.js"></script>
\t <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<style>
\t .my_row{
\t \t
\t \t margin-top: 30px;
\t \t padding: 20px;
\t }
#testme{
width:400px;
border: 3px solid blue;
}
</style>
</head>
<div id="testme">
<div id="datepicker"><input id="picked-text" type="text" size="35"/><input id="pick-button" type="button" onclick="pickADate();" value="pick"/></div>
</div>
<script type="text/javascript">
var pickedTxt = document.getElementById('picked-text'),
pickBtn = document.getElementById('pick-button'),
datepicker = new Calendar();
document.getElementById('datepicker').appendChild(datepicker.getElement());
datepicker.getElement().style.marginTop = '10px';
datepicker.callback = function() {
pickedTxt.value = datepicker.getDate().getDateString();
pickedTxt.selectionStart = 0;
pickedTxt.selectionEnd = pickedTxt.value.length;
pickedTxt.focus();
};
datepicker.onHide = function() {
pickBtn.style.display = 'inline-block';
};
\t
function pickADate() {
pickBtn.style.display = 'none';
datepicker.show();
}
</body>
</html>
例不工作 – anu