You can use offsetWidth, clientWidth, or a currentStyle/getComputedStyle hybrid depending on your browser:
HTML
<div id="someElementIdId"></div>
CSS
div {
width: 200px;
padding: 20px;
margin: 20px;
border: 5px solid black;
}
Javascript
function getStyle(x,styleProp)
{
if (x.currentStyle)
var y = x.currentStyle[styleProp];
else if (window.getComputedStyle)
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
return y;
}
function fn1(el){ return $(el)[0].currentStyle.width; };
function fn2(el){ return $(el).width(); };
function fn3(el){ return getStyle($(el)[0],'width').replace('px', ''); };
function fn4(el){ return $(el)[0].offsetWidth; };
function fn5(el){ return $(el)[0].clientWidth; };
alert( fn3('#someElementIdId') );
Note that offsetWidth will include the padding, scrollBar, and the border. If you want width + padding you can use clientWidth.
It also might help to know why you want to do this? If you are going to be using jQuery to find the element in the DOM why not use the jQuery width() function as well?
http://jsfiddle.net/A2VpH/24/
.width(): Get the current computed width for the first element in the set of matched elements..style.widthgets the width set in the CSS. It is not the same. I suggest to have a look at the implementation of.width().fn('#someElementIdId');andfn('#someElement');reference different objects. In your code the ID's are the same?