开发者

jQuery .inArray question

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);

   开发者_如何学C if ((jQuery.inArray(myindex, array)) == -1) {
        var equal = "FALSE";
    } else {
        var equal = "TRUE";
    }
    alert(equal); 
});


added parseInt() to myindex and fixed the problem.


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜