Aru Gyani
Aru Gyani

Reputation: 17

Can't access JQuery through JS file

I have created HTML, CSS, and JS documents that are all linked through the HTML doc.

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="script.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css"></link>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">         </script>
</head>
<body>
</body>
</html>

I have tested the document connections and they work fine, so how do I get the JQuery to work in the external js file?

Upvotes: 0

Views: 448

Answers (2)

Mahendra Choudhary
Mahendra Choudhary

Reputation: 81

Always Call script at end of the body tag

<!DOCTYPE html>
        <html>

        <head>
            <title></title>
            <link rel="stylesheet" type="text/css" href="style.css"></link>
        </head>

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

        </html>

Upvotes: 0

Mani
Mani

Reputation: 2655

Use library file as first and write your scripts on scripts.js.

<!DOCTYPE html>
<html>

<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css"></link>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js">
    </script>
    <script type="text/javascript" src="script.js"></script>
</head>

<body>
</body>

</html>

Upvotes: 3

Related Questions