admin管理员组

文章数量:1404773

I am having difficulty getting jQuery to load at all. I'm writing prototype in notepad++ and using Coffee Cup to rebuild my old site.

After googling multiple forums and correcting multiple items, I end up with good code that just won't load. I checked out "6 Things to Do When jQuery Doesn't Work." My script tag at the beginning has <script type="text/javascript" src="//ajax.googleapis/ajax/libs/jquery1.9.1/jquery.min.js">

Here is what I've tried so far:

  • W3schools
  • Forays into your forum questions on the load() function.
  • Setting it up in jsfiddle. It passes the script itself but there is no result.
  • Logging into my sysadmin account on my local machine in case there is some administrative prohibition against deploying script. I will try local group policy.
  • Checking my Norton 360 software for script interception.
  • Doing a script with plain Javascript. It works.
  • Checking all browsers to make sure Javascript is enabled. It is.

Here is my code. The jQuery is a plain css function that will color all the div boundaries red. I'm writing in css3 and html5. I included all the meta stuff under the doctype in case that is interfering. Also, even though html5 doesn't need text=javascript, Firefox seems to want this. Also, there is an opening script tag. Just won't display.

    <script (see google source above)>
        $(document).ready(function(){
            $("div").css("border", "3px solid red");
        });
    </script>
</head>
<body>
    <div id="shalom">Shalom</div>
    <div id="wrapper"> 
        <p>"LoremLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do </p>
    </div>
    <div> 
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi</p>  
    </div> 
</body>
</html>

I am having difficulty getting jQuery to load at all. I'm writing prototype in notepad++ and using Coffee Cup to rebuild my old site.

After googling multiple forums and correcting multiple items, I end up with good code that just won't load. I checked out "6 Things to Do When jQuery Doesn't Work." My script tag at the beginning has <script type="text/javascript" src="//ajax.googleapis./ajax/libs/jquery1.9.1/jquery.min.js">

Here is what I've tried so far:

  • W3schools
  • Forays into your forum questions on the load() function.
  • Setting it up in jsfiddle. It passes the script itself but there is no result.
  • Logging into my sysadmin account on my local machine in case there is some administrative prohibition against deploying script. I will try local group policy.
  • Checking my Norton 360 software for script interception.
  • Doing a script with plain Javascript. It works.
  • Checking all browsers to make sure Javascript is enabled. It is.

Here is my code. The jQuery is a plain css function that will color all the div boundaries red. I'm writing in css3 and html5. I included all the meta stuff under the doctype in case that is interfering. Also, even though html5 doesn't need text=javascript, Firefox seems to want this. Also, there is an opening script tag. Just won't display.

    <script (see google source above)>
        $(document).ready(function(){
            $("div").css("border", "3px solid red");
        });
    </script>
</head>
<body>
    <div id="shalom">Shalom</div>
    <div id="wrapper"> 
        <p>"LoremLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do </p>
    </div>
    <div> 
        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi</p>  
    </div> 
</body>
</html>
Share Improve this question edited Mar 11, 2013 at 21:40 Matt Ball 360k102 gold badges653 silver badges720 bronze badges asked Mar 11, 2013 at 21:33 Gershon BlackmoreGershon Blackmore 112 bronze badges 1
  • I assume the <code> tags were only present for asking this question and not in your actual HTML. – Matt Ball Commented Mar 11, 2013 at 21:40
Add a ment  | 

3 Answers 3

Reset to default 8

An HTML validator will tell you that you can't bine script tags with src and content. Separate them, like below, and make sure the script tags are property closed, and that the URL to jQuery is correct (the one in your question 404s):

<script type="text/javascript" src="//ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function(){
    $("div").css("border", "3px solid red");
});
</script>

Further, note that scheme-relative URLs (the ones that start with //) won't work if you're just opening a local HTML file, since that uses the file:// scheme.

The script src for the jQuery library, which you're using, doesn't seem to be valid. Try this: <script src="//ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js"></script>

You can't put additional code inside a <script> tag that's got a "src" attribute to load another script. You just need an additional <script> after that one where your code will reside.

本文标签: javascriptjQuery will not loadStack Overflow