Questions tagged [innertext]

the innerText is used to set or retrieve the text between the start and end tags of the object.

Description

The .innerText property sets or retrieves the text between the start and end tags of the object.

This is an IE specific property and is not supported by other browsers like FireFox, Chrome, Opera and Safari.

Syntax for Getting inner text

var text = object.innerText;

Syntax for Setting inner text

object.innerText = text;

where, text is the string that has to be set as the inner text.

References

  1. innerText - MDN Link
  2. Differences between .innerText and .textContent
  3. .innerText works in IE but not in FireFox - SO Thread
221 questions
286
votes
11 answers

Difference between innerText, innerHTML and value?

What is the difference between innerHTML, innerText and value in JavaScript?
user2819851
  • 2,911
  • 2
  • 10
  • 6
178
votes
14 answers

How to get element by innerText

How to get tag in html page, if I know what text tag contains. E.g.: SearchingText
Anton Kandybo
  • 2,410
  • 3
  • 19
  • 31
136
votes
13 answers

Javascript .querySelector find

How can I find DIV with certain text? For example:
SomeText, text continues.
Trying to use something like this: var text = document.querySelector('div[SomeText*]').innerTEXT; alert(text); But ofcourse it will not work. How can I do…
passwd
  • 1,693
  • 2
  • 10
  • 19
31
votes
2 answers

What is the difference between innerText and outerText?

After searching through web i understood the difference between innerHTML and outerHTML. However i am having hard time understanding the difference between innerText and outerText. Both appear almost same to me. Can anyone help me understand this…
Abhishek Singh
  • 9,083
  • 17
  • 67
  • 97
22
votes
2 answers

How do I choose between innerText or nodeValue?

When I need to change a text within a span element, which one should I use and what is the difference: var spnDetailDisplay=document.getElementById('spnDetailDisplay'); spnDetailDisplay.innerText=sDetail; or var…
pencilCake
  • 45,443
  • 73
  • 211
  • 346
11
votes
2 answers

Adding Hyperlink to text in JQuery

I am using innerText to add text to my object. Is there an easy way to add a hyperlink to the text? 'trend' also has a attribute called 'link'. this.node.innerText = trend.get('value');
Parag Srivastava
  • 185
  • 1
  • 2
  • 8
11
votes
4 answers

Cross-browser innerText for setting values

Let's say I have the following code:
some text