javascript - Textboxes matching table column width -


i have table textbox each column (they going used filtering). textboxes should same width corresponding column.

this far i've gotten (simplified version): http://jsfiddle.net/9uupp/

pseudo-code explaining trying current script:

document ready{     var index = 0;     each(th){         textboxnr(index).width = this.width;         index++;     } } 

as can see, textboxes doesn't match columns in width.

important: table + content generated , may change time time, have make dynamic solution. number of columns same, width may change

first child not 0th child. index should 1 initially.

look here. says children index starts 1.

then px not needed in width, value enough. check here

here updated working jsfiddle

your code should be,

$(document).ready(function () {     var index = 1;     $("#table th").each(function () {         $('input[type="text"]:nth-child('+index+')').css('width',$(this).width());         index = index+1;     }); }); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -