Skip to content

Instantly share code, notes, and snippets.

@DylanFM
Created October 28, 2009 22:50
Show Gist options
  • Save DylanFM/220947 to your computer and use it in GitHub Desktop.
Save DylanFM/220947 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Testa</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var Obj = function() {
var that = this;
this.word = "Hello";
this.method = function(id) {
var a = document.getElementById(id);
a.onclick = function() {
console.log(that.word + " " + a.childNodes[0].nodeValue);
};
};
};
window.onload = function() {
var first = new Obj(),
second = new Obj();
first.word = "Hola";
first.method("howdy");
second.method("doody");
};
</script>
<a href="#" title="" id="howdy">testa</a>
<a href="#" title="" id="doody">testa</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment