-
src of the mouse clcik
javascript question that I cant seem to figure out. Without passing the src through the tag itself <img onclick=findit(this)> how do I find what the src element and src name are through javascript... I was playing around with window.event and all I can get is window.event.target to bring up that its an HTMLImageObject. That's not what I'm looking for. I want to know the objects name so I can modify it. Any ideas?
-
like this?
You can toggle the name attribute too; objectID.name='image2';. And, you can also exchange name for id if you are coding XHTML.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<script language="JavaScript" type="text/javascript">
<!--
function findIt(objectID){
alert (objectID.name);
}
//-->
</script>
</head>
<body>
<img name="image1" onclick="findIt(this);">
</body>
</html>