最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - $(document).ready function will not fire - Stack Overflow

programmeradmin2浏览0评论

I'm attempting to create a very simple HTML document with an even less plex $(document).ready() function. However.... nothing in the function will fire. I've set alerts and breakpoints (in Chrome's debugger) and nothing works. Below is the markup.

<!DOCTYPE HTML>
<html>
<head>
<script src=".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.

I'm attempting to create a very simple HTML document with an even less plex $(document).ready() function. However.... nothing in the function will fire. I've set alerts and breakpoints (in Chrome's debugger) and nothing works. Below is the markup.

<!DOCTYPE HTML>
<html>
<head>
<script src="http://code.jquery./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.

Share Improve this question edited Apr 20, 2014 at 20:46 NealR asked Apr 20, 2014 at 20:40 NealRNealR 10.7k61 gold badges167 silver badges306 bronze badges 3
  • Do you get any errors in the console? – SLaks Commented Apr 20, 2014 at 20:41
  • Is this all the code? it seems like it was cut in the middle - or maybe this is the problem :) – Yaron U. Commented Apr 20, 2014 at 20:42
  • My apologies, I assumed it went w/o saying that I had closed the tags (my mistake). @SLaks - No, I don't get any errors in the console at all. The page loads without incident. – NealR Commented Apr 20, 2014 at 20:47
Add a ment  | 

2 Answers 2

Reset to default 9

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

<script src="http://code.jquery./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.

发布评论

评论列表(0)

  1. 暂无评论