Copy title attribute from an hmtl <span> tag onClick

I have a <span> tag with a title attribute. The title contains the application error logging text, so the user can see the error output when hovering over the span. I want to be able to copy this title text on click. How do I copy the title attribute to the user's clipboard on click, ie <span title="error log output"> in Javascript?