js-dom对checkbox处理

网页邮件管理交互与选择操作
本文介绍了一个网页界面的邮件管理交互系统,包括全选、反选、删除附件等功能,通过JavaScript实现鼠标悬停效果增强用户体验。
<!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>
<style>
.top{
background-color:#FFFF99;
color:#66CCCC;
}
.bottom{
background-color:#FFFF99;
color:#66CCCC;
}
table{
border:1px red dashed;
border-collapse:collapse;
}
td,th{
border:#999 1px solid;
}
.one{
background-color:#99CC00;
}
.two{
background-color:#CCCC00;
}
.over{
background-color:#FF9966;
}
</style>
</head>
<body onload="gehang()">
<table width="800" border="0" align="center">
<tr class="top" align="center">
<th><input type="checkbox" name="q[]" onclick="qx()" />全选</th>
<th>发件人</th>
<th>邮件名称</th>
<th>邮件内容</th>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>aaa</td>
<td>aaa</td>
<td>aaa</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>bbb</td>
<td>bbb</td>
<td>bbb</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>ccc</td>
<td>ccc</td>
<td>ccc</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>ddd</td>
<td>ddd</td>
<td>ddd</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>eee</td>
<td>eee</td>
<td>eee</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>aaa</td>
<td>aaa</td>
<td>aaa</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>bbb</td>
<td>bbb</td>
<td>bbb</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>ccc</td>
<td>ccc</td>
<td>ccc</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>ddd</td>
<td>ddd</td>
<td>ddd</td>
</tr>
<tr onmouseover="over(this)" onmouseout="out(this)" align="center">
<td><input type="checkbox" name="q[]" /></td>
<td>eee</td>
<td>eee</td>
<td>eee</td>
</tr>
<tr class="bottom" align="center">
<th><input type="checkbox" name="q[]" onclick="qx()" />全选</th>
<td colspan="3">
<input type="button" id="qx" value="全选" onclick="qx()" />
<input type="button" id="qbx" value="全不选" onclick="qbx()" />
<input type="button" id="fx" value="反选" onclick="fx()" />
<input type="button" id="del" value="删除所选附件" onclick="del()" />
</td>
</tr>
</table>
</body>
</html>
<script language="javascript" type="text/javascript">
function gehang(){
//获取所有的tr
var trlist=document.getElementsByTagName("tr");
for(var i=1;i<trlist.length-1;i++){
//进行遍历,并且判断
if(i%2==0){
trlist[i].className="two";
}else{
trlist[i].className="one";
}
var oldcolor;
//实现当鼠标移动到改行,该行背景加深
trlist[i].onmouseover=function (){
oldcolor = this.className;
//重新设定新的颜色
this.className="over";
}
trlist[i].onmouseout=function (){
//当鼠标离开,自动还原颜色

this.className=oldcolor;

}

}
}
var arrObj = document.getElementsByName("q[]");
function qx(){
for(var i=0;i<arrObj.length;i++){
arrObj[i].checked = true;
}
}

function qbx(){
for(var i=0;i<arrObj.length;i++){
arrObj[i].checked = false;
}
}

function fx(){
for(var i=0;i<arrObj.length;i++){
if(arrObj[i].checked==false){
arrObj[i].checked = true;
}else{
arrObj[i].checked = false;
}
}
}

</script>
E:\work\project\dd\yai-webui>npm list react react-dom @vitejs/plugin-react yai-webui@0.0.1 E:\work\project\dd\yai-webui +-- @vitejs/plugin-react@4.4.1 +-- antd@5.25.1 | +-- @ant-design/cssinjs-utils@1.1.3 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @ant-design/cssinjs@1.23.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @ant-design/icons@5.6.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @ant-design/react-slick@1.1.2 | | `-- react@19.1.0 deduped | +-- @rc-component/color-picker@2.0.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @rc-component/mutate-observer@1.1.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @rc-component/qrcode@1.0.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @rc-component/tour@1.15.1 | | +-- @rc-component/portal@1.1.2 | | | +-- react-dom@19.1.0 deduped | | | `-- react@19.1.0 deduped | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- @rc-component/trigger@2.2.6 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-cascader@3.34.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-checkbox@3.5.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-collapse@3.9.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-dialog@9.6.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-drawer@7.2.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-dropdown@4.2.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-field-form@2.7.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-image@7.12.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-input-number@9.5.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-input@1.8.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-mentions@2.20.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-menu@9.16.1 | | +-- rc-overflow@1.4.1 | | | +-- react-dom@19.1.0 deduped | | | `-- react@19.1.0 deduped | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-motion@2.9.5 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-notification@5.6.4 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-pagination@5.1.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-picker@4.11.3 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-progress@4.0.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-rate@2.13.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-resize-observer@1.4.3 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-segmented@2.7.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-select@14.16.7 | | +-- rc-virtual-list@3.18.6 | | | +-- react-dom@19.1.0 deduped | | | `-- react@19.1.0 deduped | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-slider@11.1.8 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-steps@6.0.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-switch@4.1.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-table@7.50.5 | | +-- @rc-component/context@1.4.0 | | | +-- react-dom@19.1.0 deduped | | | `-- react@19.1.0 deduped | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-tabs@15.6.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-textarea@1.10.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-tooltip@6.4.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-tree-select@5.27.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-tree@5.13.1 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-upload@4.9.0 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- rc-util@5.44.4 | | +-- react-dom@19.1.0 deduped | | `-- react@19.1.0 deduped | +-- react-dom@19.1.0 deduped | `-- react@19.1.0 deduped +-- react-dom@19.1.0 | `-- react@19.1.0 deduped +-- react-vue@0.0.5 | `-- react@19.1.0 deduped +-- react@19.1.0 +-- veaury@2.6.2 | +-- react-dom@19.1.0 deduped | `-- react@19.1.0 deduped `-- vuera@0.2.7 +-- react-dom@19.1.0 deduped `-- react@19.1.0 deduped
最新发布
05-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值