Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找类似于在 Opera Dragonfly 和 Firebug 中单击鼠标的元素检查器。
单击后,它将显示如何在 JavaScript 中获取该元素?有什么工具可以做到这一点吗?
应该这样做:
var element = document.elementFromPoint(x, y);
完整代码:
window.onmousemove=function(e) { elem=document.elementFromPoint(e.clientX,e.clientY); elem.style.backgroundColor="#3399ff"; }
当然,这只是一个例子,并不完美。