Hematn
If your variable is a percentage:
var myWidth = 70; $('div#somediv').width(myWidth + '%');
If your variable is in pixels and you want the percentage to occupy the parent:
var myWidth = 140; var myPercentage = (myWidth / $('div#somediv').parent().width()) * 100; $('div#somediv').width(myPercentage + '%');
Jonathan Elder Jul 31 '15 at 3:10 2015-07-31 03:10
source share