Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to target a sub-element?

Hi there!

I have some HTML that looks like this:

<div class="parent">
    <div class="child"></div>
</div>
<div class="parent">
    <div class="child"></div>
</div>

Each .parent div has its own unique tooltip, and I would like for it to appear above the .child div contained inside it. How can I do this?

I've tried something like this, but it only seems to target the very first .child div:

target: $('.child', this)

Thanks in advance,
Greg.

Comments

  • Use jQuery to loop over the parents, from there you have access to each child.

    $('.parent').each(function(i, parent) {
      Tipped.create(parent, { target: $(parent).find('.child').get(0) });
    });
    
Sign In or Register to comment.