For the first you should close the <div>-Tags correctly with </div>:

<div class="car">
<div class="car_price">content here</div>
<div class="car_details">content here</div>
<div class="car_photos">content here</div>
</div>

$('div.car div') gives you the three div-Elements inside <div class="car">.

With

$('div.car div').click(function(event){
     alert(this.className);
})

you bind a function to the click event of every enclose div-tag.

Even better is to bind the click function to enclosing tag only:

$('div.car').click(function(event){
        alert(event.target.className);
})      


HTH
Bernhard

cloudsteph schrieb:
> Is there a way of targeting nested elements by class name?  In the
> example below, I want to be able to attach a "click" event to all divs
> with ".car" class applied and then control the children within the
> ".car" div that is clicked. None of the children can have unique IDs
> unfortunately.  Any ideas anyone?  I've tried a few combinations but
> no success :(
> 
> 
> HTML:
> 
> <div class="car">
> <div class="car_price">content here<div>
> <div class="car_details">content here<div>
> <div class="car_photos">content here<div>
> <div>
> 
> The JS:
> 
> if($(".car").length > 0){
>       $(".car").click(function(){
>               do stuff to specific child elements
>       });
> }
> 

Reply via email to