mercredi 12 juillet 2017

Using && in this one if statement does not work

I have this if statement that I wanted to use but for some reason it will not work. Currently, I have the code split up by using an -else if- instead of the -&&- and everything works fine, but I really do not understand what is wrong with this syntax.

This is saying if nothing has been entered in the headline and no image has been placed in the div, inform the user that these are required.

if ( ($('.headline').val() === '') && ($('.icon-location-eventbar img').length < 1) ) { 
     // do something
} else {
     // do something else
}

Aucun commentaire:

Enregistrer un commentaire