Last active
August 29, 2015 14:22
-
-
Save aleics/bbe6fbe57c969610e3d3 to your computer and use it in GitHub Desktop.
Sending values to methods of one class (Javascript):
This file contains 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
<!-- We can call the function using the onclick function on the html --> | |
<input type="image" id="sayhi_input" onclick="pop.create('Say hi!')"> | |
<script> | |
//Declaration of the Class "Popup" | |
function Popup() { | |
} | |
Popup.prototype = { | |
constructor: Popup, //Construct | |
create: function(param) { //Function create will do one alert | |
alert(param); | |
} | |
}; | |
var pop = new Popup(); //Creating the variable of the class | |
//Or we can call the function using a Event Listener function | |
document.getElementById("sayhi_input").addEventListener("click", function() { | |
pop.create("Say hi!"); | |
}, false); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment