【问题标题】:Get child elements of element type获取元素类型的子元素
【发布时间】:2015-06-24 17:32:00
【问题描述】:

我有一张 ID 为 tableDiv 的桌子。我需要选择每个表格标题和数据单元格并动态重置它们的值,但是由于表格是使用 ASP.NET (GridView) 制作的,我无法为标题和数据元素设置类。

我知道设置 CSS 我可以这样做:

vpw = $(window).width();

$('#tableDiv').css({ 'width': vpw * 0.95 });

但是如何为表格中的标题和数据单元格选择它?

【问题讨论】:

标签: javascript jquery css asp.net gridview


【解决方案1】:

对于页眉:

$('#tableDiv th:nth-child(i)').html("New Value");

对于单元格:

$('#tableDiv tr:nth-child(i) td:nth-child(i)').html("New Value");

i 将是您要选择的孩子号码

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多