鼠标悬停突出显示页面元素 [英] Mouseover Highlighting of Page Elements

查看:153
本文介绍了鼠标悬停突出显示页面元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个已经可用的开源解决方案,或者有人指着我找到正确的方向。我正在创建一个适用于DOM元素的Firefox扩展。在Firefox和Chrome中,元素检查器会突出显示鼠标当前悬停的区域和/或元素,例如当前悬停的div或悬停在其上的按钮。我正在寻找如何实现这个功能到我自己的扩展。让我知道是否有任何解决方案,谢谢!

解决方案

尝试这样的事情:

  var lastBoxedEl; 

函数moused(e){
var target = e.target; //实验,试试e.currentTarget,e.originanalTarget
if(lastBoxedEl){
lastBoxedEl.style.outline ='none'
}
lastBoxedEl = target;
target.style.outline ='5px纯红色';

document.body.addEventListener('mouseover',moused,false);


I am looking for either an open source solution already available or for someone to point me in the right direction to find this. I am creating a Firefox extension that works for elements from the DOM. In Firefox and Chrome, there are element inspectors that highlight the region and/or element that your mouse is currently hovering over, such as the div it is currently hovered over or a button if it is hovered over that. I'm looking for how to implement that functionality into my own extension. Let me know if there are any solutions to this, thanks!

解决方案

try something like this:

var lastBoxedEl;

function moused(e) {
    var target = e.target; //experiment, try e.currentTarget, e.originanalTarget
    if (lastBoxedEl) {
        lastBoxedEl.style.outline = 'none'
    }
    lastBoxedEl = target;
    target.style.outline = '5px solid red';
}
document.body.addEventListener('mouseover', moused, false);

这篇关于鼠标悬停突出显示页面元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆