I have a table which has id 'myTable'. Now there is a textbox in which I write down the item name to find whether it exists in the myTable cell or not. To do this I have written the following code -
var retval=0;
var search = $("#searchitem").val().trim();
$("table#myTable tr td").filter(function() {
if($(this).text() == search){retval=1;alert('Same item found');}
else{retval=0;}
});
The problem is that, when it finds the same item in the table cell it shows the alertbox. But the value of my variable retval never changes. It always shows 0. How can I solve it?
console.loginstead of alerts. It's much easier to see what's happening than getting stupid boxes popping up everywhere.retvalfor? I think there's probably a better solution to whatever problem you're facing than the one you're trying to use.