鼠标滑过单元格,颜色改变,点击单元格,颜色也改变
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><TITLE>NewDocumen...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<table >
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" ">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr> <tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
鼠标滑过某一行,该行的颜色由白--蓝,现在我想实现:
当我单击,这行颜色白-蓝,并且你移走,仍为蓝色,而当你再点击其他行的时候,上一次点击的又变回白色,而新点击的变为蓝色
还望高手指点 展开
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<table >
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" ">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr> <tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
鼠标滑过某一行,该行的颜色由白--蓝,现在我想实现:
当我单击,这行颜色白-蓝,并且你移走,仍为蓝色,而当你再点击其他行的时候,上一次点击的又变回白色,而新点击的变为蓝色
还望高手指点 展开
5个回答
展开全部
单击事件是 onclick
要实现点一下变兰,再点一下变白的效果,
要接和JavaScript,对单击次数进行if判断。
这样 onmouseout就不用写了。
。。。代码稍后
要实现点一下变兰,再点一下变白的效果,
要接和JavaScript,对单击次数进行if判断。
这样 onmouseout就不用写了。
。。。代码稍后
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<tr
onclick="this.bgColor='#BDDFFF'"
onmouseout="this.bgColor='#FFFFFF'"
>
我再看看
onclick="this.bgColor='#BDDFFF'"
onmouseout="this.bgColor='#FFFFFF'"
>
我再看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<tr onclick="this.bgColor='#BDDFFF'" onmouseout="this.bgColor='#FFFFFF'" >
我再看看
我再看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function changeColor(obj){
if(obj.id==document.getElementById("colorRowId").value){
return;
}
var tempStyle = obj.className;
if(document.getElementById("colorRowId").value!=""){
var temp = document.getElementById("colorRowId").value;
var preStyle = document.getElementById("preStyle").value;
if(document.getElementById(temp).className!="style3"){
if(preStyle=="green"){
document.getElementById(temp).className = "green";
}else{
document.getElementById(temp).className = "";
}
}
}
if(obj.className!="style3"){
obj.className = "style2";
}
document.getElementById("colorRowId").value = obj.id;
document.getElementById("preStyle").value = tempStyle;
}
function selectData(obj){
var tempSpreStyle=obj.className;
if(document.getElementById("sRowId").value!=""){
var temp = document.getElementById("sRowId").value;
var sPreStyle = document.getElementById("sPreStyle").value;
if(sPreStyle=="green"){
document.getElementById(temp).className = "green";
}else{
document.getElementById(temp).className = "";
}
}
obj.className = "style3";
document.getElementById("sPreStyle").value = document.getElementById("preStyle").value;
}
//-->
</script>
<style type="text/css">
<!--
.style2 {
background-color: #ffc02b;
color: #eeeeee;
font-size: 12px;
}
.style3 {
background-color: #ccc02b;
color: red;
font-size: 12px;
}
body{
overflow:hidden;
}
-->
</style>
<input type="text" id="sPreStyle"/>
<input type="text" id="preStyle"/>
<input type="text" id="sRowId"/>
<input type="text" id="colorRowId"/>
<table >
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_1">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_2">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_3">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="changeColor(this);" onclick="selectData(this);"id="tr_4">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
还有点小问题,累了,你自己调试出来吧
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function changeColor(obj){
if(obj.id==document.getElementById("colorRowId").value){
return;
}
var tempStyle = obj.className;
if(document.getElementById("colorRowId").value!=""){
var temp = document.getElementById("colorRowId").value;
var preStyle = document.getElementById("preStyle").value;
if(document.getElementById(temp).className!="style3"){
if(preStyle=="green"){
document.getElementById(temp).className = "green";
}else{
document.getElementById(temp).className = "";
}
}
}
if(obj.className!="style3"){
obj.className = "style2";
}
document.getElementById("colorRowId").value = obj.id;
document.getElementById("preStyle").value = tempStyle;
}
function selectData(obj){
var tempSpreStyle=obj.className;
if(document.getElementById("sRowId").value!=""){
var temp = document.getElementById("sRowId").value;
var sPreStyle = document.getElementById("sPreStyle").value;
if(sPreStyle=="green"){
document.getElementById(temp).className = "green";
}else{
document.getElementById(temp).className = "";
}
}
obj.className = "style3";
document.getElementById("sPreStyle").value = document.getElementById("preStyle").value;
}
//-->
</script>
<style type="text/css">
<!--
.style2 {
background-color: #ffc02b;
color: #eeeeee;
font-size: 12px;
}
.style3 {
background-color: #ccc02b;
color: red;
font-size: 12px;
}
body{
overflow:hidden;
}
-->
</style>
<input type="text" id="sPreStyle"/>
<input type="text" id="preStyle"/>
<input type="text" id="sRowId"/>
<input type="text" id="colorRowId"/>
<table >
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_1">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_2">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
<tr onmouseover="changeColor(this);" onclick="selectData(this);" id="tr_3">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="changeColor(this);" onclick="selectData(this);"id="tr_4">
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
还有点小问题,累了,你自己调试出来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<script type="text/javascript">
var oldobj;
function trclick(obj){
if(oldobj != null){
oldobj.bgColor="#FFFFFF";
}
oldobj = obj;
obj.bgColor='#BDDFFF';
}
function mouserout(obj){
if(oldobj == obj){
return;
}
obj.bgColor='#FFFFFF';
}
</script>
<table border=1>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr> <tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
在你的基础上改了下就好了
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<script type="text/javascript">
var oldobj;
function trclick(obj){
if(oldobj != null){
oldobj.bgColor="#FFFFFF";
}
oldobj = obj;
obj.bgColor='#BDDFFF';
}
function mouserout(obj){
if(oldobj == obj){
return;
}
obj.bgColor='#FFFFFF';
}
</script>
<table border=1>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr> <tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
<tr onmouseover="this.bgColor='#BDDFFF'" onmouseout=mouserout(this) onclick=trclick(this) >
<td>aaaa</td>
<td>aaaa</td>
<td>aaaa</td>
</tr>
</table>
</BODY>
</HTML>
在你的基础上改了下就好了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |