Aru Gyani Aru Gyani - 5 months ago 15
HTML Question

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?

Answer

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>