I'm not sure, but I think the variable has to be the same as the id
It certainly does not have to be the same. In fact if (for whatever reason) you're using a global variable, it should not match the ID of any element, due to IDs being treated in some cases as global variables.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!