简体   繁体   English

$(document).ready 函数不会触发

[英]$(document).ready function will not fire

I'm attempting to create a very simple HTML document with an even less complex $(document).ready() function.我正在尝试使用更简单的$(document).ready()函数创建一个非常简单的 HTML 文档。 However.... nothing in the function will fire.但是.... 函数中的任何内容都不会触发。 I've set alerts and breakpoints (in Chrome's debugger) and nothing works.我已经设置了警报和断点(在 Chrome 的调试器中),但没有任何效果。 Below is the markup.下面是标记。

<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" />
<script>
    alert('outside');
    $(document).ready(function() {
        alert('here');
    });
</script>
</head>

Neither alerts work.两种警报都不起作用。 Not sure what I'm doing wrong here.不知道我在这里做错了什么。

<script src="http://code.jquery.com/jquery-1.11.0.min.js" />改为

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

<script>
alert('outside');
$(document).ready(function() {
    alert('here');
});
</script>

you forgot to close the arches.你忘记关闭拱门了。 and the closing tag of script.和脚本的结束标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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