If you could accept using :focus
instead of hover, you can use:
var links = document.getElementsByTagName('a');
links[0].focus();
JS Fiddle demo.
Or
var linkToFocus = document.getElementById('link');
linkToFocus.focus();
JS Fiddle demo.
This approach, obviously, requires adapting your CSS to include the a:focus
style:
a:link, a:visited {
background-color: #fff;
}
a:hover, a:focus, a:active {
background-color: #f00;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…