<script type="text/javascript">
var a = document.getElementsByTagName("IMG");//找出所有的IMG标签 测试
//var s = document.getElementById("DivContent");
//var a = s.getElementsByTagName("IMG");//找出DivContent区域内所有的IMG标签
function addClick()
{
for(i=0;i<a.length;i++)
{
a[i].attachEvent("onclick", new Function("method("+i.toString()+");"));
a[i].style.cursor = "pointer";
a[i].alt = "点我";
}
}
function method(p)
{
window.open(a[p].src);
}
addClick();
</script>
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)