Skip to content Skip to sidebar Skip to footer

Html/jquery Finding Text In Closest

Tag

I've got a table with different td's with the same ID, this is my table, in a foreach loop: ID:

.siblings().find('p.important').text();

try this

Using the button select the tr use siblings() to get the tr of the p with .important. after getting the tr use .find() to search for the p.important and finally using .text() get the value.

Solution 2:

$(".commentButton").on('click', function () {
  var id = $(document).find('p.important').html();
  alert("id is:" + id);
});

this is your button, which does not contain the item your searching. .html gets the value between the html tags

Post a Comment for "Html/jquery Finding Text In Closest

Tag"