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

jQuery text() method doesn't work on textnodes

jQuery text() method doesn't work on textNodes: $('div').contents().filter(function(){ return this.nodeType === 3; }).text("new text");
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
1
vote
1 answer

Convert textNode content to a string

Having problem with a textNode that I can't convert to a string. I'm trying to scrape a site and get certain information out from it, and when I use an XPath to find this text I'm after I get an textNode back. When I look in google development tool…
anderssinho
  • 298
  • 2
  • 7
  • 21
1
vote
0 answers

JQUERY text nodes - Find the last sentence in an Element, and wrap it in a span tag

Possible Duplicate: Given an ID, find and replace the last sentence with a span wrapper Give a DIV with a block of text with sentences, meaning a period. How does one use the JQUERY text nodes to find the last sentence and wrap just the last…
WozPoz
  • 992
  • 2
  • 15
  • 29
1
vote
2 answers

Target elements with single child AND no text nodes outside that child, using jQuery

Using jQuery, I'm trying to target all paragraph elements that only contain a child anchor element (as a direct descendent) AND that have no text nodes outside of that child element, eg:

Some link

I've tried jQuery's…
lukebm
  • 163
  • 11
1
vote
0 answers

Optimizing javascript (innerhtml, insert elements to textnodes)

So I'm making a firefox addon to highlight words and reg. expressions and I'm having some troubles optimizing it. This was the 1st attempt: function highlight (searchText, replacement) { var walker = document.createTreeWalker(document.body); …
Sdar
  • 11
  • 2
1
vote
2 answers

styling a TextNode

I'm making a simple multiple choice program using radio buttons. When the student gets an answer wrong I can put an X after her choice, but how do I make the X red? Thanks for any help, Gerard
Gerard
  • 87
  • 1
  • 2
  • 9
1
vote
4 answers

How to know if an element, created dynamically, exist?

I have this simple function: var x = document.createTextNode("ERROR"); document.body.appendChild(x); So then I need to create an IF to verify if this message exist [If this message has been created]. This is the problem, I don't know how to do…
Caio
  • 371
  • 5
  • 11
1
vote
5 answers

jQuery : Attaching mouseup event to all textnodes of a container

I want to attach a "mouseup" event on all nodes of a container, including text nodes using jQuery. How do I do that? Update: If I had some HTML fragment like this:

Some text node strong text another text node.

Currently,…
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
1
vote
4 answers

HTML/jQuery - Preventing empty text nodes

I'm trying to prevent the creation of empty text nodes whenever I add newlines, spaces (including non-breaking spaces) tabs to my HTML structure. Eg.