you can try this var divsize = $("div").width();
however if one div size differs you won't get an accurate reading so try this var divsize; $("div").each(function(i) { divsize += $("div").eq(i).width() + ', '; }); this will return the widths of each div seperated by a comma in your variable we can narrow this to only find divs with IDS var divsize; $("div").each(function(i) { if($("div").eq(i).attr("ID") { divsize += $("div").eq(i).width() + ', '; } else { } }); On Fri, Jun 5, 2009 at 7:33 PM, Ricardo <ricardob...@gmail.com> wrote: > > There is no global 'width' function in jQuery. It's a method of jquery > objects, try it this way: > > <script type="text/javascript"> > $(function(){ > console.log( $('div').width() ); > }); > > On Jun 5, 8:35 am, runrunforest <craigco...@gmail.com> wrote: > > Hi, > > > > <style type="text/css"> > > div { width:40px; height:40px; margin:10px; float:left; > > border:2px solid blue; } > > </style> > > <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> > > <script type="text/javascript"> > > $(function(){ > > var divs = $('div','body'); > > var divSize = width(divs); > > console.log(divSize);}); > > > > </script> > > <body> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > <div></div> > > </body> > > > > I want to know the width of div, i do like this, why the console says > > width(divs) is not defined ? I see in some plugins just doing it this > > way with no problem at all >