views:

3657

answers:

3

if i have :

<div class="carBig"></div>

and

<div class="car"></div>

and $(".car").size();

i get 2 items ..

+4  A: 

What version of jquery are you using?

Using this code:

<html><head><title>Testing</title>
<script type="text/javascript" src="/js/jquery/jquery-1.2.6.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
    $(".car").each(function() {
        $("#carResults").append($(".car").size());
        $("#carResults").append($(this).text());
    });
});
</script>
</head><body>
<div class="carBig">Big Car</div>
<div class="car">Regular Car</div>
<div id="carResults"></div>
</body></html>

My output document looked like this:

Big Car
Regular Car
1Regular Car

Mine only found 1 element, the one with the class of "car"...

BrianH
+1  A: 

I think you may have something funky somewhere that's throwing it off. If I run this very simple example, it works just as expected.

<html>
<head>
</head>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
     $(".car").hide();
    });
</script>
<body>
    <div id=container>
     <div class="carBig">Car Big</div>
     <div class="car">Car</div>
    </div>
</body>
</html>

You could try posting the rest of your html to see if we can figure it out.

Jeff Sheldon
A: 

there is something very strange ... i try the some thing in different site and the result is the standard..

Moran