首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

table tr鼠标滑动变更背景色,复选框全选

2012-11-23 
table tr鼠标滑动变化背景色,复选框全选html head ??? script languagejavascript src./jquery.

table tr鼠标滑动变化背景色,复选框全选

<html>
<head>
??? <script language="javascript" src="./jquery.js" ></script>
??? <title>JS获取上传文件的绝对路径,兼容IE和FF</title>
??? <script>
$(function(){
?$(".datatable thead").addClass('title');
?? $(".datatable tbody tr:even").addClass('even');//偶数行,从0开始
?? $(".datatable tbody tr:odd").addClass('odd')//单数
?//鼠标滑过高亮
?$('.datatable tbody tr').bind('mouseover',function(){
??this.className='hover';
?? }).bind('mouseout',function(){
??
???if(this.rowIndex%2==0){
??? ???? this.className='even';
??? ????}else{
??? ???? this.className='odd';?
??? ????}
???
?? });
})


//全选
function checkall(checkmainname,checkename)
{
??? $(":checkbox[name='"+checkename+"']").attr("checked",$("#"+checkmainname).attr("checked"));
}

// 如果不是全部选中? 全选取消选中? 是全部选中 全选按钮选中
function childcheck(checkmainname,checkename)
{
?? if($(":checkbox[name='"+checkename+"']:checked").length>=$(":checkbox[name='"+checkename+"']").length){
???? $("#"+checkmainname).attr("checked","checked");
?? }else{
???? $("#"+checkmainname).removeAttr("checked");
??? }
?}?
??? </script>
<style type="text/css">
.title{ background:#00FF99;}
.even{ background: #ecf6fc; }
.odd{background:#E5ECF9}
.hover{ background:#4caee6; }
</style>
</head>
<body>
???
?
?<table width="100%" border="1" name="main" id="main" onclick="checkall('main','child')" /></th>
??? <th>&nbsp;</th>
??? <th>&nbsp;</th>
??? <th>&nbsp;</th>
??? <th>&nbsp;</th>
? </tr></thead>
? <tbody>
? <tr>
??? <td><input type="checkbox" name="child" value="${id}"
?????????????onclick="childcheck('main','child')" /></td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
? </tr>
? <tr>
??? <td><input type="checkbox" name="child" value="${id}"
?????????????onclick="childcheck('main','child')" />&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
? </tr>
? <tr>
??? <td><input type="checkbox" name="child" value="${id}"
?????????????onclick="childcheck('main','child')" />&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
? </tr>
? <tr>
??? <td><input type="checkbox" name="child" value="${id}"
?????????????onclick="childcheck('main','child')" />&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
??? <td>&nbsp;</td>
? </tr>
? </tbody>
</table>

</body>
</html>

热点排行