Unable to run Jquery

jquery

#1

Hi !
I can’t understand why my code isn’t working… Is there a preference I should activate or something I should do ? is it because it’s a cdn ?
here is my code :

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Hello world from Cloud9!</title>
    </head>
    
    <body>
        <h1>Hello world!</h1>
        <p class="tagline">From Cloud9 IDE!</p>
        <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>

jQuery(".tagline").click(function() {
   alert("jQuery works!");
});

$(".tagline").click(function() {
    alert("jQuery works!");
});


    </body>
</html>

Thanks for any help you could give me
K.


#2

You did not wrap the script inside <script> tags

EDIT and place the line that imports jquery into the head tag


#3

Hi !
thanks for your help vasilenko93. It’s indeed much better with the script tag .

but i still have two alert messages :

  • JQuery is not defined; please fix or add /global jQuery/
  • is not defined; please fix or add /*global */

here is the new code :

    <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Hello world from Cloud9!</title>
        <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
    </head>
    
    <body>
        <h1>Hello world!</h1>
        <p class="tagline">From Cloud9 IDE!</p>
        <script>
            jQuery(".tagline").click(function() {
               alert("jQuery works!");
            });
            
            $(".tagline").click(function() {
                alert("Boom!");
            });
        </script>

    </body>
</html>

#4

Ignore it, I get those errors as well on c9. If the page works than its fine.

Also I import like this.
<script type="text/javascript" src="js/jquery.js"></script>


#5

Well, it’s not working :frowning: it might be because it’s a cdn but that would be a shame…
Thanks for your help


#6

Toss an s after http and before :// and try it. Also, try moving it to be the first child of the head element.


#7

thanks bb00 and everyone. it’s now working with the httpS
Have a good day.