js代理
时间:2014-05-14 07:42:30
收藏:0
阅读:307
<!doctype html> <html lang="en"> <head> <title>proxy</title> <style> img{width:200px;heigth:200px;} </style> </head> <body> <div id="aa"> <img id="img1" src="http://images.cnblogs.com/cnblogs_com/lj915/578797/o_1.jpg"> <img id="img2" src="http://images.cnblogs.com/cnblogs_com/lj915/578797/o_2.jpg"> </div> <script> document.getElementById("aa").onclick = function(e){ var target = _getTarget(e); if(target.tagName.toLowerCase() == "img") { alert(target.id); } } function _getTarget(event) { return event.target || event.srcElement; } </script> </body> </html>
评论(0)