Last active
August 29, 2015 14:26
-
-
Save rosalindwills/822668cd853ff38c0b56 to your computer and use it in GitHub Desktop.
001C -- A page using two external revealer modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>001A</title> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script src="./clickIncrementModule.js"></script> | |
<script src="./clickDecrementModule.js"></script> | |
</head> | |
<body> | |
<input type="button" name="my-button" id="my-button" value="CLICK ME" /> | |
<p>You have clicked <span id="click-count"></span> times.</p> | |
<input type="button" name="my-button2" id="my-button2" value="HIDE YOUR CLICKS" /> | |
<script> | |
$(document).ready(function() { | |
ClickIncrementModule.init(); | |
ClickDecrementModule.init(); | |
$('#my-button').click(ClickIncrementModule.receiveElementClick); | |
$('#my-button2').click(ClickDecrementModule.receiveElementClick); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ClickDecrementModule = (function(window, $) { | |
var clickCount, clickDisplay, clickButton; | |
var init = function() { | |
setupVariables(); | |
} | |
var updateClickValue = function(e) { | |
clickCount = clickDisplay.html(); | |
clickCount--; | |
clickDisplay.html(clickCount); | |
} | |
var setupVariables = function() { | |
clickDisplay = $('#click-count'); | |
clickButton = $('#my-button2'); | |
} | |
return { | |
init: init, | |
receiveElementClick: updateClickValue | |
}; | |
}(window, jQuery)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ClickIncrementModule = (function(window, $) { | |
var clickCount, clickDisplay, clickButton; | |
var init = function() { | |
setupVariables(); | |
} | |
var updateClickValue = function(e) { | |
clickCount++; | |
clickDisplay.html(clickCount); | |
} | |
var setupVariables = function() { | |
clickCount = 0; | |
clickDisplay = $('#click-count'); | |
clickButton = $('#my-button'); | |
clickDisplay.html(clickCount); | |
} | |
return { | |
init: init, | |
receiveElementClick: updateClickValue | |
}; | |
}(window, jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment