I have a table and one row contains an input field. And other row contains td values. I need to compare the value inside the input box with the td values inside table. But the oldDivision value and NewDivision values are alerted same. But not entering to the if condition. How to solve this?
$("#tblGroupItemDetails tbody tr").each(function(i, tr) {
if (!$(tr).hasClass("tdItemMaster")) {
var oldDivision = $(tr).find(".txtDivisionName").html().toLowerCase();
var NewDivision = $(".txtDivisionName").val().toLowerCase();
alert(oldDivision)
alert(NewDivision)
if (oldDivision == NewDivision) {
isDivisionExist = true;
alert(" equal")
} else {
isDivisionExist = false;
alert("not equal")
}
}
});
.trim()to botth your variables."x " == "x"will givefalsealert("[" + NewDivision + "]")(and same for other).text(), not.html().