Skip to content

Instantly share code, notes, and snippets.

Last active Jan 8, 2016
What would you like to do?
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