Questions tagged [textnode]

textNodes in DOM, HTML, XML are nodes which contain only text, rather than the other node types of element, comment, and processing instruction.

textNodes in DOM, HTML, XML are nodes which contain only text, rather than the other node types of element, comment, and .

191 questions
4
votes
2 answers

counting text node recursively using javascript

Let say I have a mark up like this Some text node.
This is another text node.
Yet another test node. my js code function countText(node){ var counter = 0; …
user429035
  • 411
  • 1
  • 5
  • 14
4
votes
0 answers

Comparing different DOM nodes which ones are more performant?

Trying to reduce the amount of DOM nodes I did some research on this, but have not found any comparing numbers, like is it better to use two DOM elements instead of two pseudo-elements or is it better to use 20-characters text-nodes instead of…
extempl
  • 2,987
  • 1
  • 26
  • 38
4
votes
6 answers

Calculate width of text node in a block level element using jQuery

Say I have:
Some variable amount of text.
How can I get the width (in pixels) of the text in the div? Keep in mind that the amount of text will vary unpredictably from div to div. Thanks!
jerome
  • 4,809
  • 13
  • 53
  • 70
4
votes
2 answers

Jsoup. Print all text nodes in order

I want to parse this with Jsoup (this is a simplification, I would be parsing entire web pages)

ABCDE

to obtain all text elements in the order they appear, this is: A B C D E I…
Marcos Fernandez
  • 556
  • 9
  • 22
4
votes
1 answer

HTML Javascript get textNode by id tagname anything?

Is there anyway to assign an id to a textNode and then retrieve that text node via that id? I've tried several different ways and keep getting errors saying cannot get property of null. My code looks something like this... var myDiv =…
Mike P
  • 419
  • 1
  • 7
  • 16
4
votes
3 answers

Dom Nodes manipulations, how remove tags which wrap my selection?

I try to explain you my "problem". I would like to know when I select a part of text, if this text is “wrapped” by html tags, and in function delete them. For example with this sentence : The car is green, and the boat is black If I…
sanceray3
  • 185
  • 2
  • 11
4
votes
3 answers

Avoid textNode creation after new line?

If I manually write those following lines in an HTML file:
A text node will be created for each new line. I wanted to understand the useCapture argument of…
baptx
  • 3,428
  • 6
  • 33
  • 42
3
votes
1 answer

adding text with whitespaces in svg text element

Im trying to add some text that contains several whitespaces to a svg text element. I'm totally desprate, because when there is more than one whitespaces after an other they are added correctly to the element but do not show up in the browser…
haemse
  • 3,971
  • 5
  • 28
  • 40
3
votes
2 answers

java dom getTextContent() issue

when i'm trying to access my xml data from doGet method of my servlet, it only outputs the value up to the white spaces, including the whole value. XML File: Apartment
tiger
  • 31
  • 1
  • 2
3
votes
1 answer

How to make text nodes with new lines in it without using "style=white-space: pre"?

I'm trying to get a textnode with new lines in it (my text contains \n and x0a). I found the way to do this, using white-space: pre, and it works, but the problem is that the content doesn't fit to the parent div, I got the new lines in the text,…
chrigu
  • 55
  • 7
3
votes
2 answers

Highlight a word of text on the page using .replace()

I'm developing a Google Chrome extension that allows you to automatically apply a highlighting CSS rule to a word that you choose. I have the following code var elements = document.getElementsByTagName('*'); for (var i=0; i
rafaelcpalmeida
  • 874
  • 1
  • 9
  • 28
3
votes
1 answer

XPath expression: selecting text nodes between element nodes

Based in the following HTML I want to extract TextA, TextC and TextE.
TextA

TextB

TextC
TextC

TextD

TextE
I tried to get TextC like so but I don't get the…
3
votes
3 answers

Javascript 'Node' undefined in IE8 and under

I have the following code which seems to work fine in all browsers except IE8 and below. $("table.availability").each( function() { var siteName = $(this).parent().siblings("h2").contents().filter(function() { return this.nodeType ==…
Tom
  • 12,776
  • 48
  • 145
  • 240
3
votes
1 answer

Ways of setting/getting a textNode's value

There are many ways to retrieve/change the value of a text node: It's not textnode.value, a XUL-only thing textContent[mdn] is not supported until IE9 data, inherited by Text from the CharacterData interface nodeValue[mdn] from the Node…
Bergi
  • 630,263
  • 148
  • 957
  • 1,375
2
votes
3 answers

Change text-nodes text

How can I change text-nodes text? HTML:

bbb foo aaa

I'm trying to change 'aaa' and 'bbb' to hello world. I successed to select those nodes but couldn't change their text. Jquery so far: var $textNodes =…
gdoron
  • 147,333
  • 58
  • 291
  • 367
1 2
3
12 13