Anil
Anil

Reputation: 63

calculate table th width in percentage instead of pixel in javascript

How to calculate table th width in percentage and assign that width to table tbody td using javascript ?

 $('#headerwidth').find('thead th').each(function(){
  var rowval = $(this).outerWidth()+'px' ;

Upvotes: 1

Views: 411

Answers (1)

Morteza Asadi
Morteza Asadi

Reputation: 1855

You probably need to write one loop inside current loop on thead:

 $('#headerwidth').find('thead th').each(function(){
     var rowval = $(this).outerWidth()+'px' ;
     $('#headerwidth').find('tbody tr td').each(function(){
        $(this).css("width", rowval)
     });
});

Upvotes: 2

Related Questions