0

I have a table with the width 100%. It has seven columns that divide up the width equally. All I want to do is to have the height of a td element be equal to it's dynamic width.

Any ideas? jquery is fine

table { width: 100%;}
NickEckhart
  • 458
  • 2
  • 8
  • 21

2 Answers2

0

You can try following code:

$( window ).resize(function() {
  $('table>tr').height($('table>td').width());
});

But. It is batter to do it with CSS. Because redraw using javascript is expensive computation.

Khamidulla
  • 2,927
  • 6
  • 35
  • 59
0

Try ...

var w = $("table td").width() + "px";
$("table td").css({ height: w });
rfornal
  • 5,072
  • 5
  • 30
  • 42