Mohamed Arifkhan A
Mohamed Arifkhan A

Reputation: 55

Add jquery in external js file

I want to add the following jquery in external javascript file.

$("a[href='#c4']").click(function() {
    $("html, body").animate({ scrollTop: 0 }, 2500);
        return false;
    });
});

How to execute this in html file?.Help me...

Upvotes: 0

Views: 653

Answers (2)

Abhijith A C
Abhijith A C

Reputation: 530

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<h1>Hello World</h1>
<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript" src="path/to/your/jsFile.js"></script>
</body>
</html>

Upvotes: 1

Luthando Ntsekwa
Luthando Ntsekwa

Reputation: 4218

First include jquery file in your html and then just include your external file after your jquery file in your html page like this:

<head>
    <script src="your_jquery_file.js"></script>
    <script src="yourexternalfile.js"></script>
</head>

Upvotes: 1

Related Questions