TypeError: $(…).timepicker is not a function

后端 未结 3 1847
囚心锁ツ
囚心锁ツ 2021-01-27 06:05

I am getting problem with Jquery timepicker(); function Here it is


    &         


        
相关标签:
3条回答
  • 2021-01-27 06:26

    One of your imports may not be working correctly since I got it working in a JSFiddle. Try redownloading the CSS/JS files and make sure they are in the correct locations. If that still doesn't work, you can use the CDN for referencing the CSS/JS files.

    Put the following in your HTML code and it should be fixed

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.1/jquery.timepicker.min.css"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.1/jquery.timepicker.min.js"></script>
    

    Also, in future, I might suggest using a CSS class instead of individual id's like so:

    $(document).ready(function () {
            $('.txt').timepicker();
        });
    
    0 讨论(0)
  • 2021-01-27 06:29
    <!DOCTYPE html>
        <html>
        <head>
    
          <link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
          <!-- Updated stylesheet url -->
          <link rel="stylesheet" href="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.css">
    
          <script src="//code.jquery.com/jquery-1.10.2.js"></script>
          <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
    
          <!-- Updated JavaScript url -->
          <script src="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.js"></script>
          <script>
    
          $(function() {
          $("#datepicker").datepicker();
        });
    
        $(function() {
          $('#timepicker1').timepicker();
        });
        $(function() {
        $("#datepicker1").datepicker();
        });
    
        $(function() {
        $('#timepicker2').timepicker();
        });
          </script>
    
        </head>
        <body style="background-color:#E8E9E9;">
          <form method="post" action="makecleaningappt">
    
            <input type="text" id="datepicker" name="date">
            <br>
            <input type="text" id="timepicker1" name="time">
    
                <input type="text" id="datepicker1" name="date">
                <br>
                <input type="text" id="timepicker2" name="time">
          </form>
    
        </body>
        </html>
    
    0 讨论(0)
  • 2021-01-27 06:31

    You may have a problem importing the files. Look: JSFiddle

    Check the external resources that I used.

    $(document).ready(function () {
            $("#txtMonday").timepicker();
            $("#txtTuesday").timepicker();
            $("#txtWednesday").timepicker();
            $("#txtThursday").timepicker();
            $("#txtFriday").timepicker();
            $("#txtSaturday").timepicker();
        });
    
    0 讨论(0)
提交回复
热议问题