Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Text of Anchor Tag In Javascript

How do I set the text of an anchor tag in javascript? This does not seem to work. I'm using firefox.

var link = document.createElement("a");
link.innerHtml = "Remove";
like image 458
Arizona1911 Avatar asked Aug 16 '10 18:08

Arizona1911


4 Answers

It is innerHTML. JavaScript is case sensitive.

like image 97
Quentin Avatar answered Nov 10 '22 20:11

Quentin


Property names are case sensitive in Javascript.

Try

link.innerHTML = "Remove";

You will need to attach the created element to the document, too. But I assume you're doing that in the rest of your code.

like image 21
Pekka Avatar answered Nov 10 '22 21:11

Pekka


innerHtml should be innerHTML (capitalized 'HTML')

like image 5
brianghig Avatar answered Nov 10 '22 21:11

brianghig


The property name is case sensitive and should be innerHTML.

like image 4
Ryan Tenney Avatar answered Nov 10 '22 20:11

Ryan Tenney