[jQuery] Re: Can jQuery calculate CSS Width/Height
Thanks Matt, but that does not work. As my example shows, the element may have a percentage width, or it could be 'auto' (which it would be if not specifically set). What I need is the 'pixel' measurement that would replicate its current size. In other words, if it currently is width:90%; and I replace it with width:985px;, the width *would not change* (assuming 985 is the pixel equivalent). On Jan 26, 3:03 pm, Matt matt.critch...@gmail.com wrote: $('#Test').css('width') ? On Jan 26, 11:46 am, Kevin Dalman kevin.dal...@gmail.com wrote: jQuery has innerHeight/Width and outerHeight/Width methods, but is there a method that can return a 'CSS Height/Width'. A CSS width is the width that would be applied via CSS to achieve a given 'outer width'. This value will differ depending on the box model and other older browser idiosyncracies. Here is an example... DIV#Test { width: 90%; height: auto; padding: 7px; margin: 11px; border: 3px solid #000; } DIV id=Test line1 BR line 2 BR line 3 /DIV Now I want to increase the DIV width height by 1-pixel. To do so, I need the current 'pixel width/height' that is equivent to its current size. AFAIK, $(#Test).innerWidth() will not address this. Is there another dimension method that can? I already have a custom function to calculate this, but I'm wondering if I am missing something in jQuery that would simplify my code? If not, I may suggest such a method for jQuery, but want to be sure it doesn't already exist! Does anyone have knowledge of this? /Kevin- Hide quoted text - - Show quoted text -
[jQuery] Re: Can jQuery calculate CSS Width/Height
with 1.3.1 I'm able to get pixel measurement from percent with no problem. example: body script src=jquery.js/script div id=d1 style=width:100%;border:1px solid black div id=d2 style=width:90%;border:1px solid black div id=d3 style=width:90%;border:1px solid black div id=d4 style=width:90%;border:1px solid black test /div /div /div /div script alert($(#d1).width()); alert($(#d2).width()); alert($(#d3).width()); alert($(#d4).width()); /script /body On Jan 28, 12:17 pm, Kevin Dalman kevin.dal...@gmail.com wrote: Thanks Matt, but that does not work. As my example shows, the element may have a percentage width, or it could be 'auto' (which it would be if not specifically set). What I need is the 'pixel' measurement that would replicate its current size. In other words, if it currently is width:90%; and I replace it with width:985px;, the width *would not change* (assuming 985 is the pixel equivalent). On Jan 26, 3:03 pm, Matt matt.critch...@gmail.com wrote: $('#Test').css('width') ? On Jan 26, 11:46 am, Kevin Dalman kevin.dal...@gmail.com wrote: jQuery has innerHeight/Width and outerHeight/Width methods, but is there a method that can return a 'CSS Height/Width'. A CSS width is the width that would be applied via CSS to achieve a given 'outer width'. This value will differ depending on the box model and other older browser idiosyncracies. Here is an example... DIV#Test { width: 90%; height: auto; padding: 7px; margin: 11px; border: 3px solid #000; } DIV id=Test line1 BR line 2 BR line 3 /DIV Now I want to increase the DIV width height by 1-pixel. To do so, I need the current 'pixel width/height' that is equivent to its current size. AFAIK, $(#Test).innerWidth() will not address this. Is there another dimension method that can? I already have a custom function to calculate this, but I'm wondering if I am missing something in jQuery that would simplify my code? If not, I may suggest such a method for jQuery, but want to be sure it doesn't already exist! Does anyone have knowledge of this? /Kevin- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text -
[jQuery] Re: Can jQuery calculate CSS Width/Height
$('#Test').css('width') ? On Jan 26, 11:46 am, Kevin Dalman kevin.dal...@gmail.com wrote: jQuery has innerHeight/Width and outerHeight/Width methods, but is there a method that can return a 'CSS Height/Width'. A CSS width is the width that would be applied via CSS to achieve a given 'outer width'. This value will differ depending on the box model and other older browser idiosyncracies. Here is an example... DIV#Test { width: 90%; height: auto; padding: 7px; margin: 11px; border: 3px solid #000; } DIV id=Test line1 BR line 2 BR line 3 /DIV Now I want to increase the DIV width height by 1-pixel. To do so, I need the current 'pixel width/height' that is equivent to its current size. AFAIK, $(#Test).innerWidth() will not address this. Is there another dimension method that can? I already have a custom function to calculate this, but I'm wondering if I am missing something in jQuery that would simplify my code? If not, I may suggest such a method for jQuery, but want to be sure it doesn't already exist! Does anyone have knowledge of this? /Kevin