jQuery UI在Firefox中工作,但不在Chrome和Safari中?

问题描述:

我使用jQuery UI,具体日期选择并自动完成,具体如下:jQuery UI在Firefox中工作,但不在Chrome和Safari中?

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> 
$("#note_date").datepicker({ 
    maxDate: 0, 
}); 

$("#note_name").autocomplete({ 
    source: ["1", "2"], 
    select: function(event, ui) { 
    } 
}); 

它们工作得很好在Firefox 3.6.8,但不要在谷歌浏览5.0.375.126和Safari 5.0在所有的工作( 6533.16)。我认为jQuery UI的东西应该在这些浏览器中工作?什么可能导致他们不工作?谢谢阅读。

请确保您还有jquery-min.js脚本。如果您在Chrome中右键单击您的页面并选择检查器,您将看到正在发生的错误。以下应工作(我所做的是增加了jQuery的min.js,让JavaScript的末被加载,添加了DOM后)

<html> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> 
</head> 
<body> 
<div id="note_date"></div> 
<div id="note_name"></div> 
<script> 
$("#note_date").datepicker({ 
    maxDate: 0, 
}); 

$("#note_name").autocomplete({ 
    source: ["1", "2"], 
    select: function(event, ui) { 
    } 
}); 
</script> 
</body> 
</html> 

我使用这两个,他们在所有现代浏览器工作。

请注意,你有你的日期选择器方法的逗号,它应该是

$("#note_date").datepicker({ 
    maxDate: 0 // no trailing comma 
}); 

看到它的工作here

至于自动完成功能,设置对我来说看起来还不错。你在使用其他JS框架吗?如果你有一个活页面,我可以进一步提供帮助。

M

使用

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> 
</script> 

,而不是

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> 
</script>