Reputation: 4125
I am trying to make a DataTables multiple row selection going, in which they use the code:
if ( $.inArray(1, 1) !== -1 ) {
$(row).addClass('selected');
}
To check if certain row have already been selected. However, every equation which I put in the $.inArray
return -1. I have tried some in the console of my browser such as $.inArray(1,3)
, $.inArray([1],[3])
, $.inArray(["1"],["3"])
, $.inArray(1,1)
, $.inArray([1],[1])
but all return -1! According to the documentation of jQuery this should be possible...
Upvotes: 0
Views: 65
Reputation: 1992
You are simply using it wrong =)
The first argument is the value
you want to find and the second argument is the actual Array
to search the value in.
So you should have something like:
var array = [1, 2, 3];
... $.inArray(1, array) ...
Upvotes: 1