jQuery check if column contains certain value

Hello friends as we use jquery for client side functionality and we need tables to show the data in tabular form. I had a requirement to to add items to a jquery datatable based on search result. If user already added searched result it doesn’t allow user to add again.

I get the solution by using below code.

 $("#table tr td:nth-child(8)").each(function () {
                    var texttocheck = this.innerText.trim();
                    if (texttocheck == "mukesh") {
                        var errMsg = "user already exists in the list";
                        alert(errMsg);
                        return false;
                    }
                    return false;
                });

In the above code I am getting the table child column 8th and then comparing the value, if that value exist it would show error message already exist.

happy coding..

Posted by | View Post | View Group