单击文本框时,我的日期选择器未显示。 我的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Picker</title>
<script src="~/Scripts/jquery-2.2.4.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<link rel="stylesheet" href="~/Content/themes/base/jquery-ui.css" />
<script type="text/javascript">
$(document).ready(function () {
$("#MyTextbox").datepicker();
});
</script>
</head>
<body>
<div>
Birth date <input type="text" name="MyTextbox" id="MyTextbox" />
</div>
</body>
</html>
当我在浏览器中使用F12时,我看到一个类&#34; hasDatepicker&#34;已自动添加。这有关系吗?为什么没有显示日期选择器?
答案 0 :(得分:1)
我不是100%肯定在这里,但我相信您的链接脚本标签或jquery和jquery-ui的版本可能会出现问题。我无法真正验证您包含的脚本标记,因为我无法为旧版本添加Google Hosted Libraries,但是在添加jQuery 2.2.1和jQuery UI 1.12.1时,您的代码似乎工作正常在下面的代码段中:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Picker</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>
<div>
Birth date <input type="text" name="MyTextbox" id="MyTextbox" />
</div>
</body>
</html>
{{1}}
答案 1 :(得分:0)
$(document).ready(function () {
$("#MyTextbox").datepicker();
});
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Picker</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>
<div>
Birth date <input type="text" name="MyTextbox" id="MyTextbox" />
</div>
</body>
</html>