I need to get a div element (.tooltip_remove_content) below a particular span(.remove-from-wishlist) in the DOM,
<div class="product-item"> <!-- This is an array -->
<div style="text-align:center;">
<span class="remove-from-wishlist">Remove</span> <!-- I attach qtip2 plugin for displaying a tooltip -->
</div>
<div class="tooltip_remove_content display-none"> <!-- tooltip content -->
<div class="tooltip-text">
<a href="#" id="A123" class="remove-from-wishlist save-wishlist-text">
Remove from Wishlist</a>
</div>
</div>
</div>
$(".remove-from-wishlist").qtip({
content:{
text:$(this).next(".tooltip_remove_content").html() // I need to get the div with class tooltip_remove_content below
// span with class remove-from-wishlist
},
hide:'unfocus',
style: "qtooltip",
position: {
my: "bottom center",
at: "top center",
target: $(".remove-from-wishlist")
}
})
You can use
.closest()andfind()method to get required div and then use.html()to return html content from that div and show same inside your plugin.Demo Code :