Arizona1911
Arizona1911

Reputation: 2201

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";

Upvotes: 14

Views: 39248

Answers (5)

Mohammad Rajob
Mohammad Rajob

Reputation: 743

You can also use this one:

link.textContent= "Remove";

Upvotes: 2

brianghig
brianghig

Reputation: 197

innerHtml should be innerHTML (capitalized 'HTML')

Upvotes: 5

Pekka
Pekka

Reputation: 449435

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.

Upvotes: 8

Ryan Tenney
Ryan Tenney

Reputation: 1841

The property name is case sensitive and should be innerHTML.

Upvotes: 4

Quentin
Quentin

Reputation: 943569

It is innerHTML. JavaScript is case sensitive.

Upvotes: 35

Related Questions