我正在尝试检查我的Jquery Library是否加载到HTML页面上。我想确认它是否可用,但是有些东西不对。以下是我的代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="/query-1.6.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
if (jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
});
</script>
<!doctype html>
就好了。 - Luke$(document)
准备函数运行,则jquery已加载。因此,您可以简单地执行$(document).ready(function(){ alert("Ready!"); });
。当然,如果jquery无法运行,这不会显示警报。但是,如果您只需要验证是否正确引用了jquery库,则足够了。 - ToolmakerSteve