Replaced JQuery call in outer scope with getElementById as JQuery doesn't return DOM object