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.th is.name_)
<html>
<head>
<script language="JavaS cript">
function ClassA(id) {
this.name_ = "class A";
this.el = document.getEle mentById(id);
this.el.onmouse over = function() {
this.style.colo r = "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.th is.name_)
<html>
<head>
<script language="JavaS cript">
function ClassA(id) {
this.name_ = "class A";
this.el = document.getEle mentById(id);
this.el.onmouse over = function() {
this.style.colo r = "red";
alert(name_);
}
}
</script>
</head>
<body onload="new ClassA('span')" >
<span id="span">i'm the <SPAN></span>
</body>
</html>
Comment