html,鼠标经过表格的某个单元格上时该单元格背景变色,不是该行背景变色,也不是仅仅文字的背景变色,

html,鼠标经过表格的某个单元格上时该单元格背景变色,不是该行背景变色,也不是仅仅文字的背景变色,,第1张

<!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=utf-8" />

<title>无标题文档</title>

<style>

.table1 {border-collapse: collapse}

.table1 tr {}

.table1 tr td {text-align:center line-height:36px}

.table1 tr td:hover { background-color:#f00 color:#fff}

</style>

</head>

<body>

<table class="table1" width="70%" border="1">

  <tr>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

  </tr>

  <tr>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

  </tr>

  <tr>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

  </tr>

  <tr>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

  </tr>

  <tr>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

    <td>测试</td>

  </tr>

</table>

</body>

</html>

给分

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>无标题文档</title>

<script language="javascript" type="text/javascript">

function tagscheck(a){

var lng=document.all.tags(a.tagName).length

for(i=0i<lngi++){

var temp=document.all.tags(a.tagName)[i]

if(a==temp){

//选中的标签样式

temp.style.background="#ccc"

}else{

//恢复原状

temp.style.background=""

}

}

}

</script>

</head>

<body>

<table width="100%" border="1" cellpadding="2" cellspacing="0">

<tr>

<td bgcolor="#006600"> </td>

<td bgcolor="#006600"> </td>

<td bgcolor="#006600"> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

<tr onclick="tagscheck(this)">

<td> </td>

<td> </td>

<td> </td>

</tr>

</table>

</body>

</html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>无标题文档</title>

<style>

td{height:15px}

</style>

<script language="javascript">

function tagscheck(a){

var lng=document.all.tags(a.tagName).length

for(i=0i<lngi++){

var temp=document.all.tags(a.tagName)[i]

if(a==temp){

//选中的标签样式

temp.style.background="#ccc"

}else{

//恢复原状

temp.style.background=""

}

}

}

</script>

</head>

<body>

<table width="100%" border="1" cellpadding="2" cellspacing="0">

<tr>

<td bgcolor="#006600"></td>

<td bgcolor="#006600"></td>

<td bgcolor="#006600"></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

<tr onmouseover="tagscheck(this)">

<td></td>

<td></td>

<td></td>

</tr>

</table>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/8377763.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-15
下一篇 2023-04-15

发表评论

登录后才能评论

评论列表(0条)

保存