gpt4 book ai didi

jquery - 时间选择器的问题

转载 作者:行者123 更新时间:2023-12-01 01:13:07 26 4
gpt4 key购买 nike

我在我的元素中使用了时间选择器,但它无法正常工作。它给了我未捕获的类型错误。

当我单击文本框时,我需要这样的输出

我尝试以这种方式使用时间选择器:

<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.css">
<title>TimePicker</title>
</head>
<body>
<div class="container">
<h2>Time Picker</h2>
<p>This example of time picker using bootstrap and jquery.</p>
<form>
<div class="form-group">
<label for="starttime">Start Time:</label>
<input type="text" class="form-control" id="starttime" readonly>
</div>
<div class="form-group">
<label for="endtime">End Time:</label>
<input type="text" class="form-control" id="endtitme" readonly>
</div>
</form>
</div>
<script>
$(".starttime").clockpicker({
twelvehour: true,
});
$("#endtitme").clockpicker({
twelvehour: true,
});
</script>
</body>
</html>

提前谢谢

最佳答案

您的代码中缺少clock js

添加clock js及其工作,并将.starttime更改为#starttime,因为它的ID在您的字段中而不是类

<script src="http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js"></script>

$("#starttime").clockpicker({
twelvehour: true,
autoclose: true
});
$("#endtitme").clockpicker({
twelvehour: true,
autoclose: true
});
<html>

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.css">
<script src="http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js"></script>
<title>TimePicker</title>
</head>

<body>
<div class="container">
<h2>Time Picker</h2>
<p>This example of time picker using bootstrap and jquery.</p>
<form>
<div class="form-group">
<label for="starttime">Start Time:</label>
<input type="text" class="form-control" id="starttime" readonly>
</div>
<div class="form-group">
<label for="endtime">End Time:</label>
<input type="text" class="form-control" id="endtitme" readonly>
</div>
</form>
</div>

</body>

</html>

在时钟选择器中添加autoclose: true

关于jquery - 时间选择器的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59558684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com