简体   繁体   中英

Error with datapicker in internet explorer

I have this code in the header:

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 

and after this script more below

 <script type="text/javascript">
            jQuery(function($){ //on document.ready
            $('#datePicker').datepicker();
            }); 
        </script> 

And in my HTML I use this sentence:

<input id="datePicker" name="datePicker" type="date" size="36" onkeypress="return postOnReturn(event)">

In chrome I can see the datapicker but in Internet Explorer i only see a empty field. And error message that it said "JQUEry isn't defined" in Console

Do you know what happen?

THX!

I try to refer your steps to produce the issue on my side with IE. I find that your code is working fine on my side without any error. Here is my testing result.

Code:

 <!doctype html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script type="text/javascript"> jQuery(function($){ //on document.ready $('#datePicker').datepicker(); }); </script> </head> <body> <input id="datePicker" name="datePicker" type="date" size="36" onkeypress="return postOnReturn(event)"> </body> </html> 

Output:

在此处输入图片说明

So we can say that this example code does not have any issue and it is working fine in IE. It is possible that some other line of code have the issue and causing this error. You can try to check the code again.

If you are using any older version of IE than I suggest you to move to IE 11. It can also help you to solve your issue. I had also test the code with various document mode and it works without any error.

You can try to make a test with my code and check whether it is running correctly or not. Let us know about your testing results.

Use this way

<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<input id="datePicker" name="datePicker" type="text" size="36" onkeypress="return postOnReturn(event)">

https://jsfiddle.net/s2yku8q7/3/

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