JavaScript怎样写谷歌首页的“更多”
http://www.google.cn/
中的那个更多用JavaScript怎么实现?不要用jQ.
HTML code:
<script type="text/javascript">
function showMenu(e) {
document.getElementById("subMenu").style.display = "block";
//防止事件冒泡
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble = true;
return false;
}
document.onclick = function() {
if (document.getElementById("subMenu").style.display = "block") {
document.getElementById("subMenu").style.display = "none";
}
}
</script>
<a href="javascript:void(0);" onclick="showMenu(event)">更多</a>
<div id="subMenu" style="position: absolute; display: none; border: 1px solid #ccc;">
<p>
<a href="#" onclick="alert(1)">menu1</a></p>
<p>
menu2</p>
</div>
非常感谢,能说说//防止冒泡事件的作用吗?
实在是太强了,谢谢!
不放置冒泡的话。点击更多,先展开,又因为document.onclick而关闭了。
1楼强啊。。真快
顶
相关问答:
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function oo(a){
document.getEleme ......
树HTML
<div id="DataTreeView" class="dtree" onclick="treeview_click(this);">
<Table> 展开 OR 折叠 </Table>
<DIV> ......
定义以下Javascript方法
JScript code:
function onSubmit(actType)
{
form.type.value = actType;
}
有以下按钮,调用该JavaScript方法
HTML code:
<html: button oncli ......
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(),this.ClientID, " <script language=\"javascript\" type=\"text/javascript\"> if(confirm('需要直接 ......