textnode

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?

百般思念 提交于 2021-02-19 09:22:12
问题 Markdown-like functionality for tooltips Problem: Using Vanilla JavaScript I want to: Change this: <div> <p> Hello [world]{big round planet we live on}, how is it [going]{verb that means walking}? </p> <p> It is [fine]{a word that expresses gratitude}. </p> </div> To this: <div> <p> Hello <mark data-toggle="tooltip" data-placement="top" title="big round planet we live on">world</mark>, how is it <mark data-toggle="tooltip" data-placement="top" title="verb means walking">world</mark>? </p> <p>

Is there a way selecting MULTIPLE areas of text with JS in Chrome and/or IE?

▼魔方 西西 提交于 2020-01-14 10:10:04
问题 Firefox 3 can select MULTIPLE areas of text with JS. Is there a way doing this in Chrome and IE? I really tried to find a way to select of multiple textareas in a web page in Chrome and IE9. Infos at: http://help.dottoro.com/ljxsqnoi.php Example at: http://jsfiddle.net/t3sWz/ Code FireFox3.5+ only... (but this is the question): <html> <head> <meta charset="UTF-8"> <style> #trigger { background: yellow } </style> </head> <body> <p id="test"> This is some text you can highlight by dragging or

Is there a way selecting MULTIPLE areas of text with JS in Chrome and/or IE?

余生颓废 提交于 2020-01-14 10:04:23
问题 Firefox 3 can select MULTIPLE areas of text with JS. Is there a way doing this in Chrome and IE? I really tried to find a way to select of multiple textareas in a web page in Chrome and IE9. Infos at: http://help.dottoro.com/ljxsqnoi.php Example at: http://jsfiddle.net/t3sWz/ Code FireFox3.5+ only... (but this is the question): <html> <head> <meta charset="UTF-8"> <style> #trigger { background: yellow } </style> </head> <body> <p id="test"> This is some text you can highlight by dragging or

In ContentEditable, how can I get a reference to the element immediately preceding the caret?

青春壹個敷衍的年華 提交于 2020-01-03 02:01:31
问题 I am trying to write a function that will, on keyup , give me a reference to the element immediately preceding the caret in a contentEditable div. If the caret is in a text node then the function should return null . If the caret is at the start of the contentEditable then the function should return null . But if the caret is at the start of a text node, and this text node is immediately preceded by an element such as a Span, then the function should return a reference to this element. And,

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

岁酱吖の 提交于 2019-12-24 08:34:25
问题 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: CGFloat) -> SCNNode { let textTodraw = SCNText(string: text3D, extrusionDepth: depthOfText) textTodraw.firstMaterial?.transparency = transparency textTodraw.firstMaterial?.diffuse.contents = color let textNode = SCNNode(geometry: textTodraw) textNode

When a mousedown and mouseup event don't equal a click

筅森魡賤 提交于 2019-12-21 09:17:45
问题 I've been using some buttons for a while now that have a depressed effect as they are clicked using position relative and a top: 1px in the :active pseudo-class. I had problems with click events not firing and it turned out to be due to the mousedown and mouseup events not firing on the same element. I did a bit of fiddling to make sure the inner-most element covered the whole button and discovered that the issue remained. If I click right at the top of the text then the link jumps down

Retrieving DOM textnode position

孤街浪徒 提交于 2019-12-18 11:46:36
问题 Is it possible to retrieve the geometric position (i.e. top/left offsets from either the parent element, the page, etc) of a text node? 回答1: Not directly. TextNode does not have the originally-IE offset* (and similar) extensions for measuring on-viewport positioning. On IE only, you could create a TextRange object, laboriously attempt to align it with the bounds of the TextNode, then measure the boundingLeft/boundingTop of the TextRange, and add it to the position of the parent element

Find all text nodes

浪尽此生 提交于 2019-12-18 04:37:07
问题 I'm trying to write a bookmarklet that calls the function doSomething(textNode) on all instances of visible text on the document. doSomething() , just for fun, replaces every word with "derp" by replacing the textContent of the textNode passed into it. However, this makes some textNodes that are empty to have words in them, so it breaks the web page. Is there a way to call doSomething() on only every textNode that has words in it? function recurse(element) { if (element.childNodes.length > 0)

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

淺唱寂寞╮ 提交于 2019-12-17 21:07:51
问题 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<elements.length; i++) { var element = elements[i]; for (var j=0; j<element.childNodes.length; j++) { var node = element.childNodes[j]; if(node.nodeType === 3) { var text = node.nodeValue; var fetchedText = text.match(/teste/gi); if(fetchedText) { var replacedText = element

Hide text node in element, but not children

孤街醉人 提交于 2019-12-17 02:46:07
问题 I'm having a little trouble with CSS and can't seem to find a solution. I have this HTML <div id="closelink"> <a href="">Close</a> Click to close </div> Now I want to hide the text «Click to close» only, without hiding neither the div, nor the link within it. Can this be done? 回答1: The visibility attribute can be overriden on children elements, so you are able to do this: <div id="closelink"> <a href="">Close</a> Click to close </div> CSS: #closelink { visibility:collapse; } #closelink a{