简体   繁体   中英

Why isn't this calendar working?

I wrote this code for calendar and it's working on one file and not on the other. Have a look:

   <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
        <link rel="stylesheet" href="style.css">
           <script>
        $(document).ready(function() {
            $( "#datepicker" ).datepicker();
        });
        </script>
        <p>Date: <input type="text" id="datepicker"></p>

Why isn't it working on just one file?

If there is another library that is using the $ variable, you can do this:

var $j = jQuery.noConflict();
$j(function() {
        $j( "#datepicker" ).datepicker();
});

Copy and paste this:

<!doctype html>

<head>
  <meta charset="utf-8">     
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>


<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
</script>

</head>

 <body>    
   <p>Date: <input type="text" id="datepicker"></p>          
 </body>
</html>

The problem is your link to JQuery-UI is invalid, fix that and it will work.

https://jsfiddle.net/jamiguel77/atg5m6ym/

//code.jquery.com/ui/1.11.4/jquery-ui.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM