解决方案 »
- 超链接添加一个click事件,出现冒泡
- 获取BODY问题
- 求助,用JQuery的append函数插入HTML代码无效
- IE7 下的Ajax小问题
- radio后面的输入框验证
- javascript语法问题,不懂语法问问而已.
- 如何使用JS修改Css里的类的属性
- 有没有百度或谷歌官方的javascript脚本 引入到我的页面后 可以有利于SEO
- 在netscape4.7下如何解决调用history.go(0)造成error message重复弹出的问题
- JavaScript 中字符串变量传递问题
- 关于删除最后一个字符串的问题。求帮助
- js怎么实现点预览按钮能在线预览PDF, 点下载按钮能下载PDF?
function cc(){
var color=["white","blue","green","orange","red"];
document.getElementById("a1").style.backgroundColor=color[Math.round(4*Math.random())];
document.getElementById("a2").style.backgroundColor=color[Math.round(4*Math.random())];
}
是,但两种颜色要不同。所以用了splice函数,但使用后ie6下就不运行了,不知何故。
但splice函数的返回值是个数组,不是字符串
function cc()
{
var color=new Array("white","blue","green","orange","red");
document.getElementById("a1").style.backgroundColor=color.splice(Math.floor(Math.random()*color.length),1)[0];
document.getElementById("a2").style.backgroundColor=color.splice(Math.floor(Math.random()*color.length),1)[0];
}
function cc(){
var color=["pink","blue","green","orange","red"].sort(function(){return 0.5 - Math.random()});
color.length=2;
document.getElementById("a1").style.backgroundColor=color[0];
document.getElementById("a2").style.backgroundColor=color[1];
}