js获取点击到的内容

js获取点击到的内容

提供给APP小组的H5页面链接,现在要求点击图片传给原生一个地址,他们展示图片。
这个方法之前没用过,在此记录一下,方便以后查找。

document.body.onclick=function(e){
        var event = window.event || e;
        var obj=document.elementFromPoint(event.clientX,event.clientY);
        console.info(obj.tagName);
        if (obj.tagName.toLocaleLowerCase() == 'img') {
            console.log(obj.src);
        }
    }

猜你喜欢

转载自blog.csdn.net/github_37125043/article/details/82189520