javascript - Change a variable value inside a Jquery .filter() function -


i have table has id 'mytable'. there textbox in write down item name find whether exists in mytable cell or not. have written 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 that, when finds same item in table cell shows alertbox. value of variable retval never changes. shows 0. how can solve it?

please try return false this

var retval=0;    var search = $("#searchitem").val().trim(); $("table#mytable tr td").filter(function() {     if($(this).text() == search){         retval=1;         alert('same item found');         return false;     }else{         retval=0;     } }); 

Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -