GCharb
06-11-2007, 02:43 AM
Hello all
I am looking for a way to change an img src in a div without calling for an id, I tried this code, seems okay to me but it does not work!
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function changeImage(o) {
o.childNodes.img.src="image2.gif";
}
</script>
</head>
<body>
<div style="display:block" onClick="changeImage(this)">
<img src="image.gif">Some text
</div>
</body>
</html>
Anyone has a suggestion?
GCharb
I am looking for a way to change an img src in a div without calling for an id, I tried this code, seems okay to me but it does not work!
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function changeImage(o) {
o.childNodes.img.src="image2.gif";
}
</script>
</head>
<body>
<div style="display:block" onClick="changeImage(this)">
<img src="image.gif">Some text
</div>
</body>
</html>
Anyone has a suggestion?
GCharb