Moved jQuery element creation code to a HTML template