Click to See Complete Forum and Search --> : hor to refer to an image within anchor?


kusi
11-12-2003, 09:34 AM
i know the id of the anchor,

<a href="#" onClick="javascript:do-sth; call a js ^fn then();"><img......>

how can i refer to this image somehow, either from within anchor or from outside??

Fang
11-12-2003, 12:42 PM
<a href="#" id="myimage" onClick="ChildImg(this);"><img alt="flagNL (1K)" src="images/myimage.gif" height="100" width="50" /></a>

as:
function ChildImg(obj) {
alert(obj.firstChild.src);
//or
alert(document.getElementById('myimage').firstChild.src);
}

kusi
11-12-2003, 01:58 PM
Thx a lot....