Search code examples
javascripthtmlinnerhtml

innerHTML doesn't work, why?


I want set new in span,

var email ='ss@ww.net';
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 ?


Solution

  • You are missing a closing " the code should read:

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