M
marius
i get "name_ is undefined" error. how should i access ClassA object
from inside this inner function/object?
in Java i would write something like this alert(ClassA.this.name_)
<html>
<head>
<script language="JavaScript">
function ClassA(id) {
this.name_ = "class A";
this.el = document.getElementById(id);
this.el.onmouseover = function() {
this.style.color = "red";
alert(name_);
}
}
</script>
</head>
<body onload="new ClassA('span')">
<span id="span">i'm the <SPAN></span>
</body>
</html>
from inside this inner function/object?
in Java i would write something like this alert(ClassA.this.name_)
<html>
<head>
<script language="JavaScript">
function ClassA(id) {
this.name_ = "class A";
this.el = document.getElementById(id);
this.el.onmouseover = function() {
this.style.color = "red";
alert(name_);
}
}
</script>
</head>
<body onload="new ClassA('span')">
<span id="span">i'm the <SPAN></span>
</body>
</html>