Simple fiddle - http://jsbin.com/mamenagu/1/edit
A more thorough fiddle - http://jsbin.com/mamenagu/7/edit
I'm working on an experimental website designer, and I ran into a problem grabbing element's css styles.
I noticed that when I set a css style to 80%. The browser retrieved it in a pixel form instead of a percentage based form.
Here's the code...
$(".montrer-largeur").html("width: " + $(".la-largeur").css('width'));
In addition when no padding, overflow, etc: is defined when I use that as the value to be retrieved I noticed it also grabbed the default value rather than leave it empty.
I know I can use the following code to grab an elements width via percentage (demo provided here)
var width = ( 100 * parseFloat($('.la-largeur').css('width')) / parseFloat($('.la-largeur').parent().css('width')) ) + '%';
$(".montrer-largeur").html(width);
However my problem is I don't want pixels being retrieved if the element's width is in a percentage based form, and I don't want to retrieve percents of the element's width is in pixels/em/etc: form
Does anyone know if there's a way to do this in JQuery?
Any help is greatly appreciated thanks.