与onmouseover()的不可用链接

时间:2012-03-29 17:59:17

标签: javascript

我尝试用onmouseover()创建一个包含一些链接的显示列表但是当我点击它们时它们不起作用:

<script language="javascript">
function displayList()
{
document.getElementById('list').innerHTML = 'More<br/><ul><li><a href="currency.php">Currency converter</a></li><li><a href="contactus.php">Contact us</a></li></ul><div id="quit" onmouseout="hideList();">Close</div>';
}

 function hideList()
{
document.getElementById('list').innerHTML = 'More';
}
</script>
<div id="list" onmouseover="displayList();">More</div>

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

这是一个解决方法:

<script language="javascript">
function displayList()
{
document.getElementById('list').setAttribute('onmouseover','');

document.getElementById('list').innerHTML = 'More<br/><ul><li><a href="currency.php">Currency converter</a></li><li><a href="contactus.php">Contact 

us</a></li></ul><div id="quit" onmouseout="hideList();">Close</div>';
}

 function hideList()
{
document.getElementById('list').setAttribute('onmouseover','displayList();');
document.getElementById('list').innerHTML = 'More';
}
</script>
<div id="list" onmouseover="displayList();">More</div>