我使用这个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