Replace jQuery attr() with native Javascript methods