Home  >  Article  >  Web Front-end  >  open 动态修改img的onclick事件示例代码_javascript技巧

open 动态修改img的onclick事件示例代码_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:15:351270browse
复制代码 代码如下:

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')");


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn