Good day,
I cant get the value of className of an object. everytime I try to display the className of an object by using window.alert(obj.className) the browser doesnt do anything. here is my code below:
javacript code for objTest.js:
[CODE]window.onload=initObj;
function initObj(){
var allTags=document.getElementsByTagName(“DIV”);
for(var i = 0; i<allTags.length;i++)
{
if(allTags[i].id.indexOf(“objTesting”) > -1){
allTags[i].onmouseover=function(){objOver(allTags[i]);}
}
}
}
function objOver(thisTag){
window.alert(“before changing class name = ” + thisTag.className);
}
and here is my html code:
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script type=”text/javascript” src=”objTest.js”></script>
<link rel=”stylesheet” type=”text/css” href=”css.css” />
</head>
<body>
<div id=”wrap”>
<div id=”objTesting” class=”myclass1″>Testing</div>
</div>
</body>
</html>
All I want is that if I roll over to that DIV with an id of ‘objTesting’ the className of that DIV will be disply in the window.alert….
any idea?
btw, I am practicing an unobtrusive method of scripting, so the scripting is all in external file.
thanks