tags:

views:

28

answers:

3

This code makes one comment box:

<div class="com_box">
  <div class="com_box">
    <div class="com_box_text"> text </div>
  </div>
</div>

<div class="com_box_info">
  <img ... />
  <div> ... </div>
  <div>
    <a href="" id="quote"> text </a>
  </div>
</div>

When i click a#quote i want to do something with the div.com_box_text over. How do i select it with jQuery?

+1  A: 

Try something like this:

$(document).ready(function() {
    $("#quote").click(function() {
        $(".com_box_tex").html("foo");
    });
});
Andrew Hare
+1  A: 
$("#quote").click(
    function(){
        var info_box = $(this).closest(".com_box_text");
        // do stuff with info_box
    }
);

Edit: I'm assuming you mean you wanted to do something with the nearest instance of that class, not with all elements of that class.

inkedmn
you are correct sir. your code didnt work though :\
cvack
+2  A: 
$(document).ready(function() {
    $("#qoute").click(function(
       $(".com_box_text").hide(); //or something else ;)
    ));
});
bruno