In this jQuery tutorial,We separates custom code in the separate custom java script file
In this jQuery tutorial,We separates custom code in the separate custom java script fileWe can separate custom code in the separate custom java script file. In this example ,we put the jQuery script in a separate file , which will save with ".js" extension. This ".js" file have all the jQuery scripting.
It's always a good practice to separate the JavaScript code into a separate file. So, beginners must understand the importance of separating the .js file into a different js file and then include it in your HTML page. Here are the benefits of separating the js file into a new file:
How to use the separate js file in HTML page?
You should create a separate js file and use the following code to include it in the HTML page:
<script type="text/javascript" src="custom.js"></script>
So, this is good and easy best practices of using the .js file in HTML page. In this example we have jQuery code in a different js file which we are including in our main HTML page and its working fine.
Here is the video of “Separate JavaScript file in jQuery HTML page”:
jqCustom.html
<html> |
custom.js
|
We can include "custom.js" file as :
<script type="text/javascript" src="custom.js"></script>
OUTPUT :