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楼强啊。。真快
顶
相关问答:
在C#中是这样调用的:
1、添加引用
2、using ReaderActxLib;
3、RichonReaderClass readerManager = new RichonReaderClass();
4、readerManager.Open();//调用com组件中open方法
现在我要在jav ......
hookkeee老师,javascript如何控制xml
如何读取cookies
hookkee在web版
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.load("test"&q ......
如下的框架定义:
<frameset cols="100,*">
<frame name="left" src="a.html">
<frameset rows="80,*">
......
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<body>
<%!
public class User{
private St ......