I have a table with a row defined like this:
<tr>
<td id="to-watch">
@Model.Results.Seats
</td>
</tr>
Edit: The table values are being updated by ajax calls to an action which is returning data to the table in a partial
I want to log to the console when the value is greater than 2, here is the jQuery code I have:
$('#to-watch')
.change(function () {
if ($('#to-watch').val() > 2) {
console.log("************ WINNER ***************");
}
});
I have checked in Chrome debugging tools nothing is being logged to the console when the value is greater than 2 - I rarely use jQuery / JavaScript, and after some looking, haven't been able to find the answer..
Edit: I'm making the ajax call like this:
$(document).ready(function () {
(function loop(i) {
setTimeout(function () {
callAjax(i);
//console.log("works " + i);
},
500); // ms
function callAjax(i) {
$.ajax({
url: '/Home/StartElection',
type: 'POST',
data: "test",
async: true
})
.done(function (partialViewResult) {
$("#partialTable").html(partialViewResult);
}).always(function () {
if (--i) loop(i);
});
};
})(650);
});