How Call link tag by id by javascript?
<im开发者_开发问答g src="images/icon2.png" border=0 onClick="window.document.getElementById('loadimg')">
<a href="images/img.jpg" id='loadimg'></a>
i want when click the image will active the link by id='loadimg' how can i do i try write onClick="window.document.getElementById('loadimg')" but not work
Than you
You can put the image in the link:
<a href="images/img.jpg" id='loadimg'>
<img src="images/icon2.png" border="0" />
</a>
It seems you want the item in the link to be loaded so something like this should work:
window.location.href = window.document.getElementById('loadimg').href;
This will cause the broswer page to navigate to this url.
Or was there something else you wanted to do?
精彩评论