Get the width of a div when width set by css class
jquery
Solution
See here you don't have a attribute of `width`:
<div id="resizable" class=">
this will surely crash and set to `undefined`, `var boxWidth = $('#resizable').attr('width');`
There are two ways getting the width of an element like:
By the `.width()` way:
$('#resizable').width();
and by `.css()` way:
$('#resizable').css('width');
Problem
This JS script gives me an alertbox saying; ``` jQuery.UI.version = 1.0.2 --- Box Width: undefined ``` How can I select the `#resizable`? ``` <head> <title></title> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <script src="jquery-1.9.1.min.js" type="text/javascript"></script> <script src="jquery-ui-1.10.2.custom.min.js" type="text/javascript"></script> <style> #resizable { width: 200px; height: 150px; padding: 5px; border: 1px solid red;} </style> <script> $(function () { var boxWidth = $('#resizable').attr('width'); alert("jQuery.UI.version = " + jQuery.ui.version + " --- Box Width: " + boxWidth); }); </script> </head> <body> <div id="resizable" class="> <div id="title"> <h2> The expanding box </h2> </div> </div> </body> ```