javascript - Getting the HTML of a DIV with another element -


i have bunch of thumbnails. of these know link in jquery script - however, need html .caption, , can't make that.

i've tried following things

$('a.thumbnail').click(function() {     $(this).closest('.caption').html()     $(this).find('.caption').html()     $(this).children('.caption').html() }); 

here's html:

<div class="thumbnail">     <a href="#" class="thumbnail">         <img src="{{ url::asset($item->image) }}" alt="">     </a>     <div class="caption" align="center">         {{ $item->name }}     </div> </div> 

this work, since .caption sibling of a:

$('a.thumbnail').click(function() {     $(this).siblings('.caption').html(); }); 

why yours don't work:

$(this).closest('.caption').html() // .caption not ancestor of $(this).find('.caption').html()  // .caption not descendant of $(this).children('.caption').html() // .caption not child of 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -