Is there a simpler way to do this?
[code=html]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″>
<script type=”text/javascript”>
function position(caller)
{
IMGs = caller.parentNode.getElementsByTagName(‘img’)
for(i=0;i<IMGs.length;i++)
if(IMGs[i] === caller)
{
alert(‘the image position is: ‘ + i)
}
}
</script>
<title>test</title>
</head>
<body>
<div id=”myImages”>
<img src=”myimage.jpg” onclick=”position(this)” width=”50″ height=”50″ alt=”image”>
<img src=”myimage.jpg” onclick=”position(this)” width=”50″ height=”50″ alt=”image”>
<img src=”myimage.jpg” onclick=”position(this)” width=”50″ height=”50″ alt=”image”>
<img src=”myimage.jpg” onclick=”position(this)” width=”50″ height=”50″ alt=”image”>
<img src=”myimage.jpg” onclick=”position(this)” width=”50″ height=”50″ alt=”image”>
</div>
</body>
</html>