Column Width Adjustment - HTML Table

I have an HTML table as shown in http://jsfiddle.net/Lijo/JN8Pm/1/ . This table is created by gridview in asp.net. Therefore, I cannot add a class to "td" inside "tr". [This is an offer in many forums; but this will not work for me due to gridview]

How can I

  • set emp id column background color to red?
  • set emp id column width to 300px?

Link

Refer to the following two tables:

1. table-layout:fixed;
2. word-wrap:break-word;
0
source share
2 answers

: http://jsfiddle.net/JN8Pm/8/

var table = $('#detailContentPlaceholder_grdTransactions'),
    trs = table.find('tr'),
    headTr = table.find('.second'),
    empHeader = $($(headTr).children('th')[1]);

table.width(table.width() + 300);

empHeader.css('background-color', 'red');
empHeader.width(300);

for (var i = 2; i < trs.length; i += 1) {    
    var td = $($(trs[i]).children('td')[1]);
    td.css('background-color', 'red');
    td.width(10);
}​

EmplID. , .

+2

- jquery

 $('tr').each(function(index) {
     if (index > 1){
        $($(this).children()[1]).css("background-color","Red");

     }
     $($(this).children()[1]).css("width","300px");
});

http://jsfiddle.net/JN8Pm/6/

jsfiddle, -

0

All Articles