javascript jQuery 日期选择器在 IE 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4157643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 10:32:30  来源:igfitidea点击:

jQuery datepicker not working in IE

javascriptjqueryinternet-explorerdatepicker

提问by Olical

I have a very basic script that sets up datepicker on three of my inputs, this script works perfectin all browsers apart from Internet Explorer, I just wondered if anyone knew why. This is allof my JavaScript for that page:

我有一个非常基本的脚本,它在我的三个输入上设置日期选择器,这个脚本在除 Internet Explorer 之外的所有浏览器中都可以完美运行,我只是想知道是否有人知道为什么。这是我对该页面的所有JavaScript:

<script type='text/javascript'>
    $(function() {
        CKEDITOR.replace('content');
        $('input.datepicker').datepicker();
        $('input[name="media"]').click(function() {
            $('fieldset.media').toggle('slow');
        });
        $('input[name="digital"]').click(function() {
            $('fieldset.digital').toggle('slow');
        });
    });
</script>

The element exists because it works in all other browsers. Firebug (Firefox addon) does not show any errors.

该元素存在是因为它适用于所有其他浏览器。Firebug(Firefox 插件)不显示任何错误。

Thanks for any help you can give.

谢谢你提供的所有帮助。

EDIT

编辑

This is what my script tag for including jQuery looks like.

这就是我用于包含 jQuery 的脚本标记的样子。

<script src='/assets/javascript/jquery.js' type='text/javascript'></script>

EDIT 2

编辑 2

It is working completely (including opacity) in IE6 and IE7, IE8 is not working.

它在 IE6 和 IE7 中完全工作(包括不透明度),IE8 不工作。

回答by Olical

I have fixed it by using individual ID's for each of the elements and changing the conditional comment for Blueprint CSS from this

我已经通过为每个元素使用单独的 ID 并从此更改蓝图 CSS 的条件注释来修复它

<!--[if IE]>

To this

对此

<!--[if lt IE 8]>

Hope this helps some people.

希望这可以帮助一些人。

回答by Brian Driscoll

I'm just throwing out a guess here, but have you tried putting your code into the .ready()handler? I'm thinking that maybe the reason why your code isn't working is that the document is not fully loaded when the code executes. So, just for kicks, try this:

我只是在这里猜测一下,但是您是否尝试过将代码放入.ready()处理程序中?我在想,您的代码无法正常工作的原因可能是代码执行时文档未完全加载。所以,只是为了踢,试试这个:

$(document).ready(function(){ /*your code here*/ });

I am able to use the datepicker control with no problems in IE7 and IE8, but my code is in the .ready handler.

我可以在 IE7 和 IE8 中毫无问题地使用 datepicker 控件,但我的代码在 .ready 处理程序中。

I cannot attest to the functionality in lower versions of IE, but I'd suspect that IE6 would have some issues.

我无法证明较低版本 IE 的功能,但我怀疑 IE6 会存在一些问题。