Skip to content

Instantly share code, notes, and snippets.

Last active January 8, 2016 23:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cstrelioff/9ca7e1085ba48a0ac19b to your computer and use it in GitHub Desktop.
counter example with external javascript files
<meta charset="utf-8" />
<script src="jquery-1.11.3.min.js"></script>
<script src="mycode.js"></script>
<h1 id="number" onclick="count();">
function count() {
counter = counter + 1;
var counter = 0;
// this code is run when DOM is loaded
$(document).ready(function (){

counter exampe with external js files

This is an example of using external javascript files and using the jquery ready() method to execute code when the DOM is loaded (ie, ready). To get this to work:

  1. Download index.html, mycode.js, and jquery-1.11.3.min.js to your computer.
    • Note that I have not include the jquery file here, you'll have to grab this from other examples at the course website.
  2. Put all of the files in the same directory or folder.
  3. Open index.html in your browser and things should work as before, except for the fact that we are using external javascript files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment