开发者

How do I find the DIV in which my cursor is placed at any moment

How do I find the DIV in which my cursor is pl开发者_开发百科aced at any moment, so I can change the formatting of that area.


I imagine what you are looking for is the CSS :hover pseudo selector. It is supported in almost every browser (In IE6 it only works on a elements). In your CSS file you could do something like this:

div:hover { background: red, border: solid 1px #000 }

Which would cause any div to change color when the mouse cursor is over the element.

You would of course scope it to just the divs you wanted to change:

#thisDiv:hover, .special:hover { background: blue }

For IE6 you can either choose not to support that functionality, or you can use javascript to add and remove .hover classes from the elements, then add that selector to your CSS rules as well.


I'm not sure that anything exists to find that directly. You could update the formatting with onmouseover and onmouseout events for the divs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜