Home Tutorial Jquery Separating custom code in different file

 
 

Share on Google+Share on Google+
Separating custom code in different file
Posted on: July 24, 2010 at 12:00 AM
Advertisement
In this jQuery tutorial,We separates custom code in the separate custom java script file

Separating custom code  in different file

We 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 .

jqCustom.html

<html>
<head>
<title>The jQuery Example</title>
<script type="text/javascript" src="jquery-1.4.2.js">
</script>

<script type="text/javascript" src="custom.js"></script>
</head>
<body>
<div id="mydiv">
Click here to see a dialogue box.
</div>
</body>
</html>

custom.js

$(document).ready(function() {
  $("div").click(function() {
  alert("Hello Friends!");
  });
});

We can include "custom.js" file as :

<script type="text/javascript" src="custom.js"></script>

OUTPUT :

Download Source Code

Click here to see demo

Advertisement

Related Tags for Separating custom code in different file:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com