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
1
vote
1 answer

How to query text-nodes from DOM, find markdown-patterns, replace matches with HTML-markup and replace the original text-node with the new content?

Markdown-like functionality for tooltips Problem: Using Vanilla JavaScript I want to: Change this:

Hello [world]{big round planet we live on}, how is it [going]{verb that means walking}?

It is [fine]{a…

Hvitis
  • 502
  • 5
  • 14
1
vote
0 answers

MarkJS does not work on last items in textnode

Using MarkJS, I run into this issue that the last word in the text often does not get highlighted. This happens when I'm using contenteditable div but I'm unsure how or when exactly this happens. See how the last 'hellooo' in the second line doesn't…
Omer S
  • 71
  • 5
1
vote
2 answers

Applying CSS across multiple TextNodes

I'm looking for a way to apply a CSS class to an arbitrary text range in an HTML document. I'm using MooTools and the the rangy library, and something like this works if there's only a single TextNode to deal with: createRange: function(start, end)…
sslepian
  • 1,881
  • 5
  • 21
  • 26
1
vote
1 answer

JS for-loop + if-statement: Catching last occurrence while conditionally updating text node

I have an array with a number of paragraphs which are to be placed inside a container until that container is »full«. Whatever does not fit into this container is to be placed into a separate container. My solution mostly works fine, with a slight…
JoSch
  • 869
  • 1
  • 15
  • 35
1
vote
1 answer

How to mark HTML DOM TextNode

I am populating all TextNodes in a page, posting their nodeValues to a remote site with an ajax query. When the associated callback is invoked, I want to somehow mark the TextNode fed to the callback function but the attributes of TextNode seem to…
Aleyna
  • 1,857
  • 4
  • 20
  • 27
1
vote
2 answers

Inserting br into a textnode

This might seem odd. I have a div with the id of 'quotes', and inside there is a blockquote. I thought it would be interesting to add line breaks, if the quoted text were poetry, and I thought you could use a '@' as a conditional line break, and…
Paulx
  • 35
  • 1
  • 6
1
vote
2 answers

How to scrape "raw" text-nodes between named elements with Cheerio

Cheerio does not like html without proper tags (who does, really?). I'm trying to scrape some menus and the content i want is between elements in the html. Is there a way to parse each of these and save them as chunks using cheerio? The menu is a 5…
herr_hest
  • 21
  • 2
1
vote
4 answers

insertBefore on multiple elements only work with the last one

I have a form with lots of input elements and there's nothing telling the user which fields are required. The problem is that I don't have access to its HTML code. So I'm writing this JavaScript: var allInputs = document.querySelectorAll("input"); …
1
vote
1 answer

Text nodes on JavaScript sometimes don't merge

When merging 3 text nodes in 3 different paragraphs, the first two ps don't merge in one of the text nodes. It should concatenate the name Robert in between two other text nodes. It only works on the last part of the loop. (see the last line for…
cDub
  • 488
  • 1
  • 6
  • 19
1
vote
1 answer

XSLT: how to match exact text value within an element and replace

I need to find a specific text value within a document,'method'and for each instance replace that text value 'method' with the following: element to replace method This 'method' value can appear several times throughout the document. The issue is…
user8337275
1
vote
0 answers

jQuery doesn't recognize identical textnodes (sometimes)

I wanted to use jQuery to tweak the copy-mechanism. I noticed that when the anchor and focus nodes of a selection were the same, the corresponding jQuery objects (compared using the .is method) were not. In Chrome and Firefox (Windows) the…
Christoph Frings
  • 427
  • 4
  • 14
1
vote
2 answers

How to place text in the certain position when using SceneKit?

I have tried to follow the same simple logic as for cylinder, box … , so just by defining the position for textNode, but it is not working. func makeText(text3D: String, position: SCNVector3, depthOfText: CGFloat, color: NSColor, transparency:…
VYT
  • 1,071
  • 19
  • 35
1
vote
0 answers

Determining the content of each wrapped line of a text node

I can use Range.getClientRects() to determine the coordinates of each wrapped line of a text node: var range = document.createRange(), cr, r, div; range.selectNode(document.body.childNodes[0]); cr=…
Rick Hitchcock
  • 35,202
  • 5
  • 48
  • 79
1
vote
3 answers

SyntaxError: expected expression, got '.'

Does someone know where this JavaScript error comes from? SyntaxError: expected expression, got '.' I get this error when using a regular expression with a slash (escaped) like el.href.match(/video\/(.*)@/)[1]; as a string passed to a function like…
baptx
  • 3,428
  • 6
  • 33
  • 42
1
vote
4 answers

Why am I not able to insert text nodes which only have zero width whitespaces set?

I am trying to insert whitespace text nodes using JS but it's simply not working. Is the innerHtml property getting ignored for a TextNode? See my JSFiddle insertWhitespace = function() { var contentEditable = document.getElementById("txt"); …
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378