Javascript 点击td标签时,获取td中的p标签值之一
请帮帮我 我想检测td上的窃听。但我还需要在点击时获取p标签(cal_date)值之一。 如何获取cal_日期值 JQUERY当前代码:Javascript 点击td标签时,获取td中的p标签值之一,javascript,jquery,html,Javascript,Jquery,Html,请帮帮我 我想检测td上的窃听。但我还需要在点击时获取p标签(cal_date)值之一。 如何获取cal_日期值 JQUERY当前代码: $( document ).on ( "tap", "td", function(event) { //code here // i want to get the cal_date value in this block }); 我不能用这种方式,因为它只能检测p.cal_日期标签上的点击,而不能检测td标签上的点击 $( documen
$( document ).on ( "tap", "td", function(event) {
//code here
// i want to get the cal_date value in this block
});
我不能用这种方式,因为它只能检测p.cal_日期标签上的点击,而不能检测td标签上的点击
$( document ).on ( "tap", ".cal_date", function(event) {
});
HTML:
7
16
在点击的TD中找到.calu date
元素,并获取其文本
$(document).on ("tap", "td", function(event) {
var value = $(this).find('.cal_date').text();
});
在
点击处理程序中,此引用点击的td
元素,因此您可以使用.find()
获取其中的cal\u date
元素
$(document).on("tap", "td", function(event) {
//code here
// i want to get the cal_date value in this block
var cal_date = $(this).find('.cal_date').text()
});
谢谢这正是我想要的!
$(document).on("tap", "td", function(event) {
//code here
// i want to get the cal_date value in this block
var cal_date = $(this).find('.cal_date').text()
});