我如何从jquery中的html表中提取从时间,到时间(约会时间)

how i extract From time,To time(appointment time) from html table in jquery

本文关键字:时间 提取 约会 jquery 中的 html      更新时间:2023-09-26

我正在拖动时隙单元格时选择时隙。选择时间段后,我在文本框中输入患者姓名,然后单击选择按钮,然后患者姓名进入所选时间段。用户可以为多重患者姓名选择多个时隙,然后单击分配按钮,我必须将患者姓名与时隙(不时)插入数据库。

我在获得分配的时间段时遇到问题,即。从时间和到时间在jquery中。

$("#btnAllot").click(function () {
    //how i get alloted time here.
    $('tr').each(function () {
        $(this).find('td').each(function () {
            if ($(this).hasClass('yell')) {
                alert($(this).closest('tr').find('td:eq(1)').text());
            };
        });
    });
}

我在上面使用过,但只得到分钟而不是患者名称,小时。在此处查看实时JSBIN演示见小提琴

您只能获得分钟,因为您只选择时隙列值,请参阅更新的小提琴:

$("#btnAllot").click(function() {
    $('tr:gt(0)').each(function() {
        if ($(this).has("td[class='yell']")){
            var hour = $(this).find('td:eq(0)').text();
            var slot = $(this).find('td:eq(1)').text();
            var name = $(this).find('td:eq(2)').text();
            var msg = 'Hour: ' + hour + ' Slot: ' + slot + ' Name: ' + name;
            alert(msg);
        }
    });
});