I have found many help for ‘string contain specific substring’ when substring is known so we can specify like – “Number”.in(Str)) OR Str.indexOf(“Number”)
But in my case both String and sub string loaded at run time so i tried like –
function compareTables1(row,kk) {
$('#table2 tr').each(function(p) {
if (!this.rowIndex) return; // skip first row
var customer = $(this).find("td").eq(0).html();
if (customer.trim() == row.trim()) {
checkme(this, kk);
}
else
{
if (row.in(customer)) { //why this does not work????
alert("success sub str check");
}}});
}
link to entire code is –
http://jsfiddle.net/w7akB/55/
I am learning Jquery & sure missing something small here.
thanks for help in advance.
using indexOf works. When using indexOf, when value is -1 then it doesn’t contain the string.
Its because you need to trim your string. Updated fiddle works
http://jsfiddle.net/w7akB/60/