如何使用jquery进行更多的控制
本文关键字:控制 何使用 jquery | 更新日期: 2023-09-27 17:57:41
我在页面中为一个文本框设置了时间选择器,我想将其用于该页面中的更多文本框?!
<head>
<script type="text/javascript">
$(document).ready(function () {
$('#example8', '#TextBox1').timepicker({
ampm: true
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" name="example8" id="example8" value="" />
</div>
</form>
</body>
您可以执行类似的操作
<script type="text/javascript">
$(document).ready(function () {
$('.needstimepicker').timepicker({
ampm: true
});
});
</script>
<div>
<input type="text" class="needstimepicker" name="example8" id="example8" value="" />
<input type="text" class="needstimepicker" name="example8" id="example9" value="" />
<input type="text" class="needstimepicker" name="example8" id="example10" value="" />
</div>
您需要在单个字符串中使用,
选择器:
$("#this, #that").whatever()
try something like this
<head>
<script type="text/javascript">
$(document).ready(function () {
$('.timepicker', '#form1').timepicker({
ampm: true
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" class="timepicker" name="picker1" id="picker1" value="" />
<input type="text" class="timepicker" name="picker2" id="picker2" value="" />
<input type="text" class="timepicker" name="picker3" id="picker3" value="" />
</div>
</form>
</body>
试试这个:
<script type="text/javascript">
$(document).ready(function () {
$('.needstimepicker').each(function(){
$(this).timepicker({
ampm: true
});
});
});
</script>
<div>
<input type="text" class="needstimepicker" name="example8" id="example8" value="" />
<input type="text" class="needstimepicker" name="example8" id="example9" value="" />
<input type="text" class="needstimepicker" name="example8" id="example10" value="" />
</div>