点击事件给一个td设了背景,当下我撤消我先行的动作回到前一个背景下,条件我不确定前面那个是什么背景 点击事件给一个td设了背景,然后我想撤消我先行的动作回到前一个背景下,条件我不确定前面那个是什么背景!不知道大侠们有没有什么好方法试过<input type="reset">类似于reset的功能,但这个方法当前背景回不去 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你用什么方式设的背景用style么?建议用class方式的付值.重置后removeclass就行 这样的话用隐域这个方法就不是很合适了,window.history这个方法又不行.这个页没有前进后退历史.. <html> <head> <style type="text/css"> .over{ background:red; } .cur{ background:blue; } </style> <script type="text/javascript"> function over(o){ o.oldClass = o.className; o.className = "over"; } function out(o){ o.className = o.oldClass; } </script> </head> <body> <div style='width: 400px; height: 100px; cursor: pointer;' class="cur" onmouseover="over(this);" onmouseout="out(this);"></div> </body></html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>undoColor.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript"> var colorAry = ["red", "blue", "green", "yellow", "white", "darkorchid"]; var tempAry = []; function setColor(td) { var i = parseInt(Math.random()*(6)+1); td.style.backgroundColor = colorAry[i-1]; tempAry.push(colorAry[i]); document.getElementById('c').innerHTML = tempAry.join(','); } function undoColor(td) { if (tempAry.length > 0) { td.style.backgroundColor = tempAry[tempAry.length - 1]; tempAry.pop(); } else { alert("最后一个了"); } document.getElementById('c').innerHTML = tempAry.join(','); } </script> </head> <body> <div id="c"></div> <table border="1"> <tr> <td onclick="setColor(this)" id="t">改变</td> </tr> </table> <input type="button" value="undo" onclick="undoColor(document.getElementById('t'))"/> </body></html> 关于 window中onbeforeunload的应用 全国省市县三级联动 选到县后显示邮编 不想用数据库 Javascript textbox光标定位到最后一位 报错“由于出现错误 800a025e 而导致此项操作无法完成” safari下如何将本地的xml文件载入xml解析器??急急急!!! js的问题 正则式 url替换 JS高手帮忙,看看如何实现框架页面的传值(分不够我再加) net_lover帮我!meizz帮帮我!(想在iframe里显示纯文本) 一个很菜的问题。 能不能用js实现这么一个功能啊! jquery 的全选 怎么不灵呀,有代码 JS控制DIV中的ID值
<head>
<style type="text/css">
.over{
background:red;
}
.cur{
background:blue;
}
</style>
<script type="text/javascript">
function over(o){
o.oldClass = o.className;
o.className = "over";
}
function out(o){
o.className = o.oldClass;
}
</script>
</head>
<body>
<div style='width: 400px; height: 100px; cursor: pointer;' class="cur" onmouseover="over(this);" onmouseout="out(this);"></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>undoColor.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var colorAry = ["red", "blue", "green", "yellow", "white", "darkorchid"];
var tempAry = [];
function setColor(td) {
var i = parseInt(Math.random()*(6)+1);
td.style.backgroundColor = colorAry[i-1];
tempAry.push(colorAry[i]);
document.getElementById('c').innerHTML = tempAry.join(',');
}
function undoColor(td) {
if (tempAry.length > 0) {
td.style.backgroundColor = tempAry[tempAry.length - 1];
tempAry.pop();
} else {
alert("最后一个了");
}
document.getElementById('c').innerHTML = tempAry.join(',');
}
</script> </head>
<body>
<div id="c"></div>
<table border="1">
<tr>
<td onclick="setColor(this)" id="t">改变</td>
</tr>
</table>
<input type="button" value="undo" onclick="undoColor(document.getElementById('t'))"/>
</body>
</html>