Javascript Pass Element To Function Properly The Head