$(function() {
to
$(window).load(function() {
to give the DOM time to be finished, then the width will work
On Jun 5, 7: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
No comments:
Post a Comment