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楼强啊。。真快
顶
相关问答:
要做一个Flash幻灯片的效果,图片、链接都是用PHP读出来的,而要把所有的链接放在Javascript中,怎么在这两种脚本之间传值?
JScript code:
<SCRIPT>
var sohuFlash2 = new sohuFlash("http://ww ......
在C#中是这样调用的:
1、添加引用
2、using ReaderActxLib;
3、RichonReaderClass readerManager = new RichonReaderClass();
4、readerManager.Open();//调用com组件中open方法
现在我要在jav ......
我在学习中,碰到问题,在处理的时候希望用脚本代码去调用C#后台代码。怎么办?
ajax异步调用呗
ajax,
webservice
后台方法:
protected string CsharpVoid(string strCC)
{
strC ......
txt是本页面中TextBox控件的id,我想用下面这种形式改变它的值,但是有问题,错误提示是:'document.getElementById(...)'为空或不是对象。
Response.Write(" <script language='Javascript& ......