see fiddle if patient has time slot alloted already then make color yellow using jquery(client side). in my fiddle if i allot time slot first time then color is green and at the same time when allot next time slot then previous time slot is grey. i have to make it yellow. for that i have to find span tag in table and check wheather contains text or not if contains text then make it yellow.But i m new in jquery.i search lot but not getting. how can i do that.
//This is button click code
$("#<%=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;
});
});
if($('span').text().length == 0){
console.log('No Text');
}
else{
console.log('Has Text');
}
Demo: http://jsfiddle.net/hj4Bt/1/
Use $(this).find("span").text()
instead. Check if the returned string is empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With