Grab an element's outer <a> element
Posted: Thu Nov 30, 2006 6:13 pm
I have an image wrapped in an anchor tag...
I have a reference to the image tag... how would I use that to grab the <a> tag that is it's parent?
I want to disable the <a> tag's href but the only thing I have access to is the image
Code: Select all
<a href="#url"><img src="#href" alt="Image" id="i_am_an_image"></a>Code: Select all
var img1 = document.getElementById('i_am_an_image');
//img1.parentNode ??