Skip to content

Instantly share code, notes, and snippets.

@aleics
Last active August 29, 2015 14:22
Show Gist options
  • Save aleics/bbe6fbe57c969610e3d3 to your computer and use it in GitHub Desktop.
Save aleics/bbe6fbe57c969610e3d3 to your computer and use it in GitHub Desktop.
Sending values to methods of one class (Javascript):
<!-- 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