1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to select a outer outer div???

Discussion in 'jQuery' started by WillPooleDesigns, Jun 18, 2014.

  1. #1
    <div>
    <a>
    <img>
    </a>
    <p></p>
    </div>
    ---------------
    <div>
    <a>
    <img>
    </a>
    <p></p>
    </div>
    ----------------

    All I want to do is using the img tag selected as $(this) to select the contents of <p> tag in the outer div??

    var thumbcap = $j(this).parent('a').closest(p).html(); ??? This selects always the firs div p content.

    Thank you in advance...
     
    WillPooleDesigns, Jun 18, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    $(this).parents('div').find('p').html(); should work - however, in the code you provided there's no "outer" div - there are consequtive divs - ie, first one div, containing an A, an IMG and a P-tag, then another DIV containing the same.
     
    PoPSiCLe, Jun 20, 2014 IP