I am trying to define variables based on if certain Id's exist. Example:
if (document.querySelector("a#sell")) {
var sell;
} else if (document.querySelector("a#buy")) {
var buy;
} else if (document.querySelector("a#area")) {
var area;
} else {
var contact;
}
It isn't working. If I define them without the if/else statements below they work just fine:
var sell = document.querySelector("a#sell");
var buy = document.querySelector("a#buy");
var area = document.querySelector("a#area");
BUT I have to have the if/else statements so any contact form without those id's would behave different. What am I doing wrong?