html中table加常用class属性,如何在html col中使用class属性

看这里

http://www.w3.org/TR/CSS21/tables.html#columns

您只能使用cols设置边框,背景,宽度和可见性

编辑

jQuery解决方案

使用这个小jQuery代码片段,您可以将col标记中的所有类名复制到相应的td标记

它甚至可以在coland td标签和嵌套表中使用colspan.

JavaScript的

$(document).ready(function() {

var find_TDs_at_COL = function(table, col) {

var ret = [];

$(table).children('tbody').children('tr').each(function() {

var col2 = 0;

$(this).children('td,th').each(function() {

oldCol2 = col2;

if ($(this).attr('colspan')) {

col2 += parseInt($(this).attr('colspan'));

} else {

col2++;

}

if (oldCol2 <= col && col2 > col) {

ret.push(this);

}

})

})

return $(ret);

}

$('table > colgroup').each(function() {

var $table = $(this).parent();

var col = 0;

$(this).children('col').each(function() {

var oldCol = col

if ($(this).attr('colspan')) {

col += parseInt($(this).attr('colspan'))

} else {

col++;

}

for (var i = oldCol; i < col; i++) {

find_TDs_at_COL($table, i).addClass($(this).attr('class'))

}

})

})

})​

$(document).ready(function() {

"use strict";

var find_TDs_at_COL = function(table, col) {

var ret = [];

$(table).children('tbody').children('tr').each(function() {

var col2 = 0;

$(this).children('td,th').each(function() {

var oldCol2 = col2;

if ($(this).attr('colspan')) {

col2 += parseInt($(this).attr('colspan'));

} else {

col2++;

}

if (oldCol2 <= col && col2 > col) {

ret.push(this);

}

})

})

return $(ret);

}

$('table > colgroup').each(function() {

var $table = $(this).parent();

var col = 0;

$(this).children('col').each(function() {

var oldCol = col

if ($(this).attr('colspan')) {

col += parseInt($(this).attr('colspan'))

} else {

col++;

}

for (var i = oldCol; i < col; i++) {

find_TDs_at_COL($table, i).addClass($(this).attr('class'))

}

})

})

})

.left-info

{

font-size:14px;

font-family:Tahoma, Helvetica, sans-serif;

color:#1A5B71;

font-weight:bold;

text-align:right;

}

.right-info

{

font-size:14px;

font-family:Tahoma, Helvetica, sans-serif;

color:#00FFFF;

font-weight:bold;

text-align:left;

}

.extra-info {

font-size:14px;

font-family:Tahoma, Helvetica, sans-serif;

color:#ff0000;

font-style: italic;

text-align:right;

}

.additional-info {

font-size:10px;

font-family:Tahoma, Helvetica, sans-serif;

color:#ffdd00;

}

ABCCCD
3476896My first HTMLExtraYesAdd
5869207My first CSSUghDon't trust
54379My first JSTrust
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值