Gershon Blackmore
Gershon Blackmore

Reputation: 11

jQuery will not load

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.com/ajax/libs/jquery1.9.1/jquery.min.js">

Here is what I've tried so far:

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>

Upvotes: 0

Views: 1518

Answers (3)

Matt Ball
Matt Ball

Reputation: 359826

An HTML validator will tell you that you can't combine 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.com/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.

Upvotes: 8

Pointy
Pointy

Reputation: 413717

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.

Upvotes: 1

Frederick Andersen
Frederick Andersen

Reputation: 304

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

Upvotes: 2

Related Questions