【发布时间】:2025-12-03 21:20:03
【问题描述】:
我有自动生成的 html 表格,这个表格的一些单元格有 rowspan 属性。如何选择这个单元格?
【问题讨论】:
我有自动生成的 html 表格,这个表格的一些单元格有 rowspan 属性。如何选择这个单元格?
【问题讨论】:
这可能会起作用:
$(document).ready(function() {
$('table td[rowspan="*"]').css('background-color', 'red');
});
或者这个:
$(document).ready(function() {
$("table td").each(function () {
if ($(this).attr("rowspan"))
$(this).css('background-color', 'red')
});
});
【讨论】:
$( "[rowspan]" )
会给你所有带有rowspan属性的标签
【讨论】:
$(document).ready(function() {
$('table').find('td[rowspan]').css('background-color', 'red');
// or
// $('table').find('td[rowspan=2]').css('background-color', 'red');
});
【讨论】: