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的变量的值的呢?
现在我 ......
树HTML
<div id="DataTreeView" class="dtree" onclick="treeview_click(this);">
<Table> 展开 OR 折叠 </Table>
<DIV> ......
hookkeee老师,javascript如何控制xml
如何读取cookies
hookkee在web版
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.load("test"&q ......
txt是本页面中TextBox控件的id,我想用下面这种形式改变它的值,但是有问题,错误提示是:'document.getElementById(...)'为空或不是对象。
Response.Write(" <script language='Javascript& ......