AnuRaj
AnuRaj

Reputation: 233

how get the value of the closest td using class name

I trying to get value of the closest using class name.

var remaningHoursValue = $(this).closest('td').find('.remainingHours');

I getting the value using id but by using class name i am not able to get result properly. result is [object, object]. From this result how to get the value in td.

Upvotes: 1

Views: 1345

Answers (2)

Rajarshi Das
Rajarshi Das

Reputation: 12330

$('*').closest('td.remainingHours');

for text of the element

 $('*').closest('td.remainingHours').text();

for log and alert()

  alert($('*').closest('td.remainingHours').text());

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388326

you need

$(this).closest('td.remainingHours');

your selector, finds the closest td element and searches for an element with class remainingHours inside it

Upvotes: 2

Related Questions