查看 fiddle 如果患者已经分配了时间段,则使用jQuery(客户端)使颜色变为黄色。 在我的fiddle中,如果我第一次分配时间段,则颜色为绿色,同时当分配下一个时间段时,则上一个时间段为灰色。我必须将其变为黄色。 为此,我必须找到表格中的span标签并检查其中是否包含文本 如果包含文本,则将其变为黄色。但我是jquery中的新手。我搜索很多但是没有得到。 我该怎么做。
//这是按钮点击代码
$("#<%=btnSelect.ClientID%>").click(function () {
var cells = $('#tableAppointment tbody tr td:nth-child(3)');
var i = 0;
var topcell = false;
cells.each(function ()
{
var $cell = $(this);
if ($cell.hasClass('csstdhighlight'))
{
if (i == 0)
{
$cell.find('span').text(jQuery('#<%=txtPatientName.ClientID%>').val());
topcell = $cell;
}
else
{
$cell.remove();
}
i++;
}
});
if (topcell && i > 1) topcell.attr('rowspan', i);
$("#tableAppointment tr").each(function ()
{
$('td', this).each(function ()
{
var value = $(this).find("span").val();
if (!value)//i m chking like this
{
}
else
{ //make it yellow
}
})
})
return false;
});
});
$('#tableAppointment tbody tr td:nth-child(3)')
返回的是一个元素,使用 each 是多余的。 - Ram