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