open 动态修改img的onclick事件示例代码
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:varimgsrc=document.getElementById("imgsrc").getElementsByTagN...
复制代码 代码如下:
var imgsrc = document.getElementById("imgsrc").getElementsByTagName('img');
imgsrc[0].style.cursor="hand";
imgsrc[0].onclick = new Function( "openArticle('/RssCommServlet?catalogid=29')");
imgsrc[1].style.cursor="hand";
imgsrc[1].onclick = new Function( "openArticle('/RssCommServlet?catalogid=30')");
imgsrc[2].style.cursor="hand";
imgsrc[2].onclick = new Function( "openArticle('/RssCommServlet?catalogid=31')");
<>