This function seems unnecessary. jQuery does the job for you.