replaced $('#' + var) by $('[id="' + var + '"]')