简体   繁体   中英

create email link from JS

In Java Script have this expression that returns an email address:

calendarMonth[i].events[j].email

I want to create an html link so with after clicking in this email a person will open an email like outlook. I am trying to use this model

<a href="mailto:email@echoecho.com?subject=SweetWords">
Send Email</a> 

but I am having lots of problem with the assembling of the html code using JS. I was trying

var email = '<b>Email: </b>'+ ' <a href="mailto:'+ 
calendarMonth[i].events[j].email+'"> <br/>';

Any suggestions?

Your general idea is right, you just messed up the HTML syntax. You're missing the contents of the anchor and the </a> closing tag.

var email = '<b>Email:</b> <a href="mailto:' + calendarMonth[i].events[j].email + '">' + 
            calendarMonth[i].events[j].email + '</a>';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM