I'm having problem with Jquery inArray.
//Get selected devices
selectedDevices = $('.selectDevices').val();
console.log(selectedDevices);
//If nothing selected, do nothing
if(selectedDevices == null || selectedDevices == ""){}
//Else remove devices not selected
else{
//Loop thru table rows with class "enhet"
$.each( $('td.enhet'), function() {
thisDevice = $('.enhet').text();
var found = $.inArray(thisDevice, selectedDevices);
console.log(found);
if (found > -1) {
console.log(thisDevice);
}
else {
console.log('nope');
}
})
}
Console.log(selectedDevices) give:
["GulAvformning", "RosaAvformning"]
Console.log(found) give: (everytime!!)
-1
Console.log(thisDevice) give:
``
Console.log('nope') give:
nope
Even if thisdeviceexists in selectedDevices i get the else case.
What am i missing?
selectedDevices is an array. I checked it by: console.log(selectedDevices[1]); And it gave me one of the devices.
thisDevice = $('.enhet').text();what is the value ofthisDevice