Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I move hovered node to new place it is still displayed as hovered. How can I unhover it?

In IE7 and IE8 when I move hovered link to new place it is still displayed as hovered. In Firefox and Chrome link is displayed as unhovered. In the example below if you click on the link it will be moved to the second row but will still be red. Is it possible to fix such behavior?

<style>
a { color:blue; }
a:hover { color:red; }
</style>
<div id="div1">
    First Row
    <a id="a1" href="javascript:void(0);" onclick="document.getElementById('div2').appendChild(this);">Click It</a>
</div>
<div id="div2">
    Second Row
</div>

Live example

like image 235
Artem Latyshev Avatar asked Nov 05 '22 07:11

Artem Latyshev


1 Answers

I don't like it, but cloning the node and removing the original seems to work:

<a id="a1" href="javascript:void(0);" onclick="document.getElementById('div2').appendChild(this.cloneNode(true)); this.parentNode.removeChild(this);">Click It</a>

Live example

There, instead of actually moving the node, we do a deep clone of it (cloneNode(true)) and append that instead. Then we remove the original (this.parentNode.removeChild(this)). This seems to avoid keeping the state information IE is keeping.

like image 110
T.J. Crowder Avatar answered Nov 10 '22 19:11

T.J. Crowder