Uses the right method setAttribute.

Works better, and the html elements get their attributes.