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楼强啊。。真快
顶
相关问答:
请大家注意看清楚问题,不是一般网上讨论的问题:
在index.php中引用js文件
<script src='index.js'> </script>
而在index.js中是怎样引用index.php中php的变量的值的呢?
现在我 ......
这个对话框是CS里弹出来的
public static void MsgBox_(Page Page, string Msg)
{
ClientScriptManager ClientScriptManager ......
JScript code:
<script language="javascript" type="text/javascript">
function $(e) {return document.getElementById(e);}
document.getElementsByClassName = function(cl) {
......
如题!
javascript 如何遍历树节点,可得到节点的 title 值
ding
引用
ding
谢谢
你可以通过id的规律遍历,为通用起见我写了个递归函数如下:
HTML code:
<html xmlns="http ......