views:

278

answers:

2

i'm having a parent div and inside that child element will be table.

i'm hidding some columns in the table thro' css becoz to avoid inline-style.

so how can i reflect the width to parent div after hidding the column of table...

+1  A: 
$("#yourtableid").width();

returns the computed pixel width of the table element with id yourtableid.

$("#yourdivid").width ( $("#yourtableid").width() );

will set the parent div width.

See

CSS/width

rahul
due to some padding margin i'm getting little more value than wat table appears.so div is little bigger than table...
santose
A: 

Maybe you'll need to use jQuery innerWidth() method (calculates elements width with padding without calculating border width) and outerWidth() (calculates elements width with padding and border size included). I you'll supply optional boolean argument to outerWidth() like outerWidth(true) it'll include also size of margins.

So in this case your code will be

$("#yourdivid").width ( $("#yourtableid").innerWidth() );

Hope it'll help.

Mushex Antaranian