按钮旁边的Div菜单

时间:2011-04-07 08:56:48

标签: javascript button html menu

我有简单的html页面:

<html>
    <head></head>
    <body>
    <table>
        <tr>
            <td>
                <input type="image" src="http://backticket.com.ua/Img/addNew.jpg" onmouseover="ShowMenu();" onmouseout="HideMenu();" />
            </td>
            <td>
                Some text that should be under appeared menu
            </td>
        </tr>
        <tr>
            <td colspan="2">
                Some text that Some text that Some text that
            </td>
        </tr>
    </table>

    <div id="divMenu" style="display:none; width: 258px; padding: 8px 0px; border: solid 1px #CCC; background-color:White">
        <div style="float: left; width: 140px; padding: 6px 2px;">
            <a href="javascript:window.print();">Print Page</a>
        </div>
        <div style="float: left; width: 140px; padding: 6px 2px;">
            <a href="#" onclick="return showEmailToFriendPopup();" class="vi_link">Email to a Freind</a>
        </div>
        <div style="float: left; width: 140px; padding: 6px 2px;">
            <a href="#">Add to Favorites</a>
        </div>
    </div> 

    <script type="text/javascript">
        function ShowMenu() {
            document.getElementById('divMenu').style.display = '';
        }

        function HideMenu() {
            document.getElementById('divMenu').style.display = 'none';
        }

    </script>

    </body>
</html>

我需要在按钮旁边的隐藏div中显示一个菜单(在右侧),而不是页面上的其他文本和元素。此外,菜单应该可见,直到鼠标按下按钮或菜单,例如AddThis服务中的悬停按钮。

谁可以帮助我使用javascript?

谢谢!

1 个答案:

答案 0 :(得分:0)

在表格周围加一个div-tag,给它CSS样式值“float:left”。 然后,给“divMenu”CSS样式值“float:right”。

其余的似乎工作正常,至少在Firefox中。