1

I want to check if my row id is within in an array. If I set a fixed value to myindex it works but as it is below it always returns the FALSE value.Thank you.

$('#stripeMeSubSubCat tr').each(function(){
    myindex = $.trim($(this).closest("tr").attr("id"));

    var array = [ 0, 52, 53 ];

    alert(myindex);
    alert(array);

    if ((jQuery.inArray(myindex, array)) == -1) {
        var equal = "FALSE";
    } else {
        var equal = "TRUE";
    }
    alert(equal); 
});

2 Answers 2

1

You need to convert the string variable ( myindex ) into int using parseInt function ..

Sign up to request clarification or add additional context in comments.

Comments

0
var  myindex = +$.trim($(this).closest("tr").attr("id"));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.