user737065
user737065

Reputation: 397

innerHTML doesn't work, why?

I want set new in span,

var email ='[email protected]';
document.getElementById('spanEmail').innerHTML='<a class="f14 bold rose" href="mailto:'+email+'>'+email+'</a>';

but this way not working , but this working

document.getElementById('spanEmail').innerHTML='sample text>';

How replace this span content ?

Upvotes: 1

Views: 4668

Answers (2)

evasilchenko
evasilchenko

Reputation: 1870

You are missing a closing " the code should read:

document.getElementById('spanEmail').innerHTML='<a class="f14 bold rose" href="mailto:'+email+'">'+email+'</a>';

Upvotes: -1

Rob Hruska
Rob Hruska

Reputation: 120456

You haven't closed your href attribute with a double-quote.

href="mailto:'+email+'>

Should be

href="mailto:'+email+'">

Upvotes: 3

Related Questions