Mar 28, 2011

Mouseover-capturing trick when a span has children

Problem


The problem occurs when a span has children but you want to capture mouseover event over the span

Solution


The most elegant solution is to
1. add position:relative to the span
2. add a child span





3. Attach all events to the newly added child span instead.

It will be on top; if it doesn't, add z-index.