简体   繁体   English

如何使用类名获取最接近的td的值

[英]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. 我使用id获取值,但是使用类名无法正确获得结果。 result is [object, object]. 结果是[object,object]。 From this result how to get the value in td. 从该结果如何获得td中的值。

you need 你需要

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

your selector, finds the closest td element and searches for an element with class remainingHours inside it 你的选择,找到最接近的td元素和搜索具有类元素remainingHours里面

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

for text of the element 用于元素的文本

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

for log and alert() 用于日志和警报()

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM