Javascript – jQuery multiple conditions within if statement

javascriptjquery

What is the syntax for this loop to skip over certain keys? The way I have it written is not working properly.

 $.each(element, function(i, element_detail){
    if (!(i == 'InvKey' && i == 'PostDate')) {
        var detail = element_detail + ' ';
        $('#showdata').append('<div class="field">' + i + detail + '</div>');
       }
 });

Best Solution

Try

if (!(i == 'InvKey' || i == 'PostDate')) {

or

if (i != 'InvKey' || i != 'PostDate') {

that says if i does not equals InvKey OR PostDate