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
277 questions
332
votes
14 answers

Difference between innerText, innerHTML and value?

What is the difference between innerHTML, innerText and value in JavaScript?
user2819851
  • 3,371
  • 3
  • 12
  • 6
299
votes
17 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
  • 3,678
  • 4
  • 23
  • 31
236
votes
14 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
  • 2,883
  • 3
  • 12
  • 22
37
votes
2 answers

"(408) ***-****\nVerified"

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
  • 10,243
  • 22
  • 74
  • 108
24
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
  • 51,323
  • 85
  • 226
  • 363
21
votes
2 answers

Retrieve innerText of hidden element

I'm trying to get an element's innerText but Chrome returns an empty string because my element is hidden. Firefox does not. Is there a way to retrieve the innerText in Chrome even if the element is…
powerbuoy
  • 12,460
  • 7
  • 48
  • 78
15
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
  • 235
  • 1
  • 3
  • 8
12
votes
2 answers

document.querySelectorAll get innerText of ALL selected elements at once pure javascript

I want to get all innerText of a whole column of a very long html table (random length). I'm using this code: var tbEls = document.querySelectorAll('#tBodyID tr td:nth-child(cidx)'); Where cidx = the column index I want to extract content from. But…
willy wonka
  • 1,440
  • 1
  • 18
  • 31
11
votes
2 answers

How can I write out decoded HTML using HTMLAgilityPack?

I am having partial success in my attempt to write HTML to a DOCX file using HTMLAgilityPack and the DOCX library. However, the text I'm inserting into the .docx file contains encoded html such as: La ciudad de Los Ángeles (California) ha…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
11
votes
4 answers

Cross-browser innerText for setting values

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