<HTML>
<HEAD>
<SCRIPT>
function fnFireEvents()
{
div.innerText = "The cursor has moved over me!";
btn.fireEvent("onclick");
}
</SCRIPT>
</HEAD>
<BODY>
<h1>Using the fireEvent method</h1>
By moving the cursor over the DIV below, the button is clicked.
<DIV ID="div" onmouseover="fnFireEvents();">
Mouse over this!
</DIV>
<BUTTON ID="btn" ONCLICK="this.innerText='I have been clicked!'">Button</BUTTON>
</BODY>
</HTML>
<HEAD>
<SCRIPT>
function fnFireEvents()
{
div.innerText = "The cursor has moved over me!";
btn.fireEvent("onclick");
}
</SCRIPT>
</HEAD>
<BODY>
<h1>Using the fireEvent method</h1>
By moving the cursor over the DIV below, the button is clicked.
<DIV ID="div" onmouseover="fnFireEvents();">
Mouse over this!
</DIV>
<BUTTON ID="btn" ONCLICK="this.innerText='I have been clicked!'">Button</BUTTON>
</BODY>
</HTML>
#===============================================================================================
本文介绍了一个使用HTML与JavaScript实现的功能,通过将鼠标悬停在一个指定的DIV元素上时触发按钮的点击事件。此方法展示了如何利用JavaScript来模拟用户交互。
3197

被折叠的 条评论
为什么被折叠?



