Skip to content
Advertisement

How do you dynamically set a recipient in a mailto link?

I’m trying to dynamically set the recipient of my mailto link in javascript. I thought that I could just put a javascript variable in the recipient place of the link, but I get errors when trying to do so. Anyone have any suggestions of why this might not be working?

This is what I currently have, which is throwing errors inside my code.

JavaScript

Advertisement

Answer

either pull out the concatenation out of the href or use bacticks to fill the href.

JavaScript
Advertisement