I am doing the following:
if ($('#selectYears option[value="' + $(this).val() + '"]') != null || $('#selectYears option[value="' + $(this).val() + '"]') != [] ) {
console.log("inside if")
$('#selectYears option[value="' + $(this).val() + '"]').remove().appendTo($('#selectYears'))
} else {
console.log("inside else")
$('#selectedYears option[value="' + $(this).val() + '"]').remove().appendTo($('#selectYears'))
}
})
If i do $('#selectYears option[value="my value"]')
in Chrome's console I get []. But I am printing out inside if (therefore my check is failing). I need to get into the else in this case. Where am I wrong?