开发者

how to use jquery for more control?

开发者 https://www.devze.com 2023-03-08 10:30 出处:网络
I have timepicker in page for one textbox, i want to use it for more textboxes in this page?! <head>

I have timepicker in page for one textbox, i want to use it for more textboxes in this page?!


<head>
<script type="text/javascript">
    $(document).ready(function () {
        $('#example8', '#TextBox1').timepicker({
            ampm: true                
        });
    });
</script>
</head>
<body>
<form id="form1" runat="se开发者_运维百科rver">
<div>
    <input type="text" name="example8" id="example8" value="" />
</div>    
</form>
</body>


You can do something like this

        <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> 


You need to use the , selector in a single string:

$("#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>


Try this:

<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> 
0

精彩评论

暂无评论...
验证码 换一张
取 消