js实现word的调色下拉按扭 请问什么地方有js实现下拉菜单的效果列子, 就好像word的调色板按扭那样的效果。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GOOGLE一下到处都是啊http://www.google.cn/search?hl=zh-CN&q=JS+%E4%B8%8B%E6%8B%89+%E8%8F%9C%E5%8D%95&meta=&aq=f&oq= http://hi.baidu.com/chinaphper/blog/item/b77b9151dff64f1b377abe37.html 我想可能我说的不清晰, 我要的不是下拉菜单的效果, 是一个按扭, dropdownlist的按扭, 就好像是word的颜色选择器那样的效果。 差不多这样的?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><style type="text/css">.color{border:solid 1px #000000;width:140px;position:absolute;display:none;}.color div{overflow:hidden;width:10px;height:10px;margin:2px;float:left;}</style><body><button onclick="show()" id="picker">show</button><script type="text/javascript">var div = document.createElement("div");div.className = "color";var color = ["00","33","66","99","cc","ff"];for(var i=0;i<10;i++){ for(var j=0;j<10;j++) { var index = getIndex(); var d = document.createElement("div"); d.style.backgroundColor = "#"+color[index[0]]+color[index[1]]+color[index[2]]; div.appendChild(d); } var br = document.createElement("br"); div.appendChild(br);}document.body.appendChild(div);function getIndex(){ var index = new Array(); index.push( parseInt(Math.random()*100,10) %6 ); index.push( parseInt(Math.random()*100,10) %6 ); index.push( parseInt(Math.random()*100,10) %6 ); return index;}function getDomOffset(id){ var el = document.getElementById(id); for(var lx=0,ly=0;el!=null; el=el.offsetParent) { lx+=el.offsetLeft; ly+=el.offsetTop; } return {x:lx,y:ly} } function show(){ var btn = document.getElementById("picker"); if(div.style.display=="block") { btn.innerHTML = "隐藏"; div.style.display="none"; return; } else { btn.innerHTML = "显示"; div.style.display="block"; } var pos = getDomOffset("picker"); var left = pos.x + 5; var top = pos.y + btn.clientHeight + 5; div.style.left = left+"px"; div.style.top = top+"px"; }</script></body></html> 是这样的, 如果我想下拉如此的菜单呢, 电击button, 下拉出这样的菜单, 该如何实现? 7楼不是已经有了,你就把button替换为图片按钮就好了 把button的换成img就好了啊<button onclick="show()" id="picker">show</button><img src="你图片地址" onclick="show()" id="picker" /> js控制div层 Jquery制作树形菜单 分享一个js效果--对图片禁止用右键 这个是什么意思 |zyciis| 200分 求一个JS二级菜单 第二贴 xiaojing7 给的菜单有问题不像我要的那个 jsp 页面 问题 快来帮帮新手啊 谢谢了!!在线等啦 JavaScript脚本,运行过程中出现“脚本大量运行,可能使浏览器速度变慢“的提示 关于网页中回车即确定 一个多个关联的下拉列表框怎么做? js按需加载大文本文件 关于前后台传递数组的问题! js怎样实现frame框架的页面刷新!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<style type="text/css">
.color{border:solid 1px #000000;width:140px;position:absolute;display:none;}
.color div{overflow:hidden;width:10px;height:10px;margin:2px;float:left;}
</style>
<body>
<button onclick="show()" id="picker">show</button>
<script type="text/javascript">
var div = document.createElement("div");
div.className = "color";
var color = ["00","33","66","99","cc","ff"];
for(var i=0;i<10;i++)
{
for(var j=0;j<10;j++)
{
var index = getIndex();
var d = document.createElement("div");
d.style.backgroundColor = "#"+color[index[0]]+color[index[1]]+color[index[2]];
div.appendChild(d);
}
var br = document.createElement("br");
div.appendChild(br);
}
document.body.appendChild(div);function getIndex()
{
var index = new Array();
index.push( parseInt(Math.random()*100,10) %6 );
index.push( parseInt(Math.random()*100,10) %6 );
index.push( parseInt(Math.random()*100,10) %6 );
return index;
}function getDomOffset(id)
{
var el = document.getElementById(id);
for(var lx=0,ly=0;el!=null; el=el.offsetParent)
{
lx+=el.offsetLeft;
ly+=el.offsetTop;
}
return {x:lx,y:ly}
} function show()
{
var btn = document.getElementById("picker");
if(div.style.display=="block")
{
btn.innerHTML = "隐藏";
div.style.display="none";
return;
}
else
{
btn.innerHTML = "显示";
div.style.display="block";
}
var pos = getDomOffset("picker");
var left = pos.x + 5;
var top = pos.y + btn.clientHeight + 5;
div.style.left = left+"px";
div.style.top = top+"px";
}
</script>
</body>
</html>
<button onclick="show()" id="picker">show</button><img src="你图片地址" onclick="show()" id="picker" />