时间选择器问题
Issue with timepicker
我在我的项目中使用了 timepicker,但它不起作用 properly.It 给我未捕获的类型错误。
当我点击文本框时我需要这样的输出
我试过以这种方式使用时间选择器:
<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>
提前致谢
您应该添加 clockpicker 库,但您只添加了样式表。在 ...bootstrap-clockpicker.min.css
行
之前添加 http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js
您的代码中缺少 clock js
添加 clock js
及其工作并将 .starttime
更改为 #starttime
因为它在您的领域中的 id 不是 class
<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
在 document.ready 中尝试。
你也没有 class 'starttime' 的元素
将 .starttime 更改为 #starttime
<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>
$(function() {
$("#starttime").clockpicker({
twelvehour: true,
});
$("#endtitme").clockpicker({
twelvehour: true,
});
});
</script>
</body>
</html>
如果还是不行
将 'clockpicker' class 放入 div 标签。
<div class="form-group clockpicker">
<label for="starttime">Start Time:</label>
<input type="text" class="form-control" id="starttime" readonly>
</div>
<div class="form-group clockpicker">
<label for="endtime">End Time:</label>
<input type="text" class="form-control" id="endtitme" readonly>
</div>
我在我的项目中使用了 timepicker,但它不起作用 properly.It 给我未捕获的类型错误。
当我点击文本框时我需要这样的输出
我试过以这种方式使用时间选择器:
<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>
提前致谢
您应该添加 clockpicker 库,但您只添加了样式表。在 ...bootstrap-clockpicker.min.css
行
http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js
您的代码中缺少 clock js
添加 clock js
及其工作并将 .starttime
更改为 #starttime
因为它在您的领域中的 id 不是 class
<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
在 document.ready 中尝试。
你也没有 class 'starttime' 的元素 将 .starttime 更改为 #starttime
<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>
$(function() {
$("#starttime").clockpicker({
twelvehour: true,
});
$("#endtitme").clockpicker({
twelvehour: true,
});
});
</script>
</body>
</html>
如果还是不行 将 'clockpicker' class 放入 div 标签。
<div class="form-group clockpicker">
<label for="starttime">Start Time:</label>
<input type="text" class="form-control" id="starttime" readonly>
</div>
<div class="form-group clockpicker">
<label for="endtime">End Time:</label>
<input type="text" class="form-control" id="endtitme" readonly>
</div>