鼠标悬停最左边10px的元素? [英] Mouseover left-most 10px of element?

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

问题描述

当鼠标悬停在单元格最左侧的10个像素上时,我需要更改表格单元格的颜色。目前我有:

I need to change the color of a table cell when the mouse hovers over the left-most 10 pixels of the cell. Currently I have this:

$("#myTable table thead tr th:nth-child(3)").mouseover(function () {
    $(this).css("background-color", "red");
});
$("#myTable table thead tr th:nth-child(3)").mouseout(function () {
    $(this).css("background-color", "white");
});

这适用于悬停在整个元素上,但我只需要在左上方悬停时 - 大约10px。

This works for hovering over the whole element, but I need it to only happen when hovering over the left-most 10px of it.

推荐答案

您可以使用 mousemove ,并检查偏移坐标:

You could use mousemove instead and check offset coordinates:



这篇关于鼠标悬停最左边10px的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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