dom

How to find a DOM element by its text content?

房东的猫 提交于 2020-12-31 05:28:33
问题 I try to add new SVG elements to some nodes. For that purpose the nodes the elements are to be added to have to be found by a string contained in there text content, e.g. find any node which has "id0" inside the <text> tag. Here is example of my HTML hierarchy: <pre> <svg> <g> <g> <text> id3 </text> <text> 73% </text> <svg> ... </svg> </g> <g> <svg> ... </svg> </g> <g> <text> id0 </text> <text> 11% </text> <svg> ... </svg> </g> <g> <text> id1 </text> <text> 66% </text> <svg> ... </svg> </g>

Drawing a table with vanilla JS and loops

强颜欢笑 提交于 2020-12-30 02:14:20
问题 I am doing an exercise (from Beginning Javascript) to better understand DOM manipulation. Attempting to recreate the following table in a DRY method using only JS (the textbook solution is here): <table> <tr> <td>Car</td> <td>Top Speed</td> <td>Price</td> </tr> <tr> <td>Chevrolet</td> <td>120mph</td> <td>$10,000</td> </tr> <tr> <td>Pontiac</td> <td>140mph</td> <td>$20,000</td> </tr> </table> I tried this but unsure how you can loop variable creation without throwing an error: var array = [[

Drawing a table with vanilla JS and loops

爷,独闯天下 提交于 2020-12-30 02:12:47
问题 I am doing an exercise (from Beginning Javascript) to better understand DOM manipulation. Attempting to recreate the following table in a DRY method using only JS (the textbook solution is here): <table> <tr> <td>Car</td> <td>Top Speed</td> <td>Price</td> </tr> <tr> <td>Chevrolet</td> <td>120mph</td> <td>$10,000</td> </tr> <tr> <td>Pontiac</td> <td>140mph</td> <td>$20,000</td> </tr> </table> I tried this but unsure how you can loop variable creation without throwing an error: var array = [[

Drawing a table with vanilla JS and loops

坚强是说给别人听的谎言 提交于 2020-12-30 02:10:51
问题 I am doing an exercise (from Beginning Javascript) to better understand DOM manipulation. Attempting to recreate the following table in a DRY method using only JS (the textbook solution is here): <table> <tr> <td>Car</td> <td>Top Speed</td> <td>Price</td> </tr> <tr> <td>Chevrolet</td> <td>120mph</td> <td>$10,000</td> </tr> <tr> <td>Pontiac</td> <td>140mph</td> <td>$20,000</td> </tr> </table> I tried this but unsure how you can loop variable creation without throwing an error: var array = [[

DOM TreeWalker to return all text nodes

放肆的年华 提交于 2020-12-29 16:46:08
问题 I'm trying to get access to all text nodes within a given element, so that I can isolate words and wrap them in spans. TreeWalker seems to be the API for the job, but I'm finding it to be extremely unintuitive. Neither the spec nor the MDN reference (usually so good at explaining arcane DOM APIs) are self-evident to my eyes. My first assumption was that all I needed to pass was the right filter as second argument - something like document.createTreeWalker( element, NodeFilter.TEXT_NODE ) .

DOM TreeWalker to return all text nodes

狂风中的少年 提交于 2020-12-29 16:45:54
问题 I'm trying to get access to all text nodes within a given element, so that I can isolate words and wrap them in spans. TreeWalker seems to be the API for the job, but I'm finding it to be extremely unintuitive. Neither the spec nor the MDN reference (usually so good at explaining arcane DOM APIs) are self-evident to my eyes. My first assumption was that all I needed to pass was the right filter as second argument - something like document.createTreeWalker( element, NodeFilter.TEXT_NODE ) .

DOM TreeWalker to return all text nodes

删除回忆录丶 提交于 2020-12-29 16:45:24
问题 I'm trying to get access to all text nodes within a given element, so that I can isolate words and wrap them in spans. TreeWalker seems to be the API for the job, but I'm finding it to be extremely unintuitive. Neither the spec nor the MDN reference (usually so good at explaining arcane DOM APIs) are self-evident to my eyes. My first assumption was that all I needed to pass was the right filter as second argument - something like document.createTreeWalker( element, NodeFilter.TEXT_NODE ) .

DOM TreeWalker to return all text nodes

和自甴很熟 提交于 2020-12-29 16:40:12
问题 I'm trying to get access to all text nodes within a given element, so that I can isolate words and wrap them in spans. TreeWalker seems to be the API for the job, but I'm finding it to be extremely unintuitive. Neither the spec nor the MDN reference (usually so good at explaining arcane DOM APIs) are self-evident to my eyes. My first assumption was that all I needed to pass was the right filter as second argument - something like document.createTreeWalker( element, NodeFilter.TEXT_NODE ) .

DOM TreeWalker to return all text nodes

混江龙づ霸主 提交于 2020-12-29 16:39:30
问题 I'm trying to get access to all text nodes within a given element, so that I can isolate words and wrap them in spans. TreeWalker seems to be the API for the job, but I'm finding it to be extremely unintuitive. Neither the spec nor the MDN reference (usually so good at explaining arcane DOM APIs) are self-evident to my eyes. My first assumption was that all I needed to pass was the right filter as second argument - something like document.createTreeWalker( element, NodeFilter.TEXT_NODE ) .

Chrome extension: Insert fixed div as UI

百般思念 提交于 2020-12-29 03:48:05
问题 I want to insert a div into a fixed position using a chrome extension. It will overlay the page that you are currently viewing. My concern is that I want this to work on any page without altering it (other than inserting my fixed div), but I don't know if that is possible with the way that I'm doing it. Currently, the button won't show up, and I had a lot of trouble getting the div to show up. By the way, the positioning is just temp for now, I will position it correctly once I get it on the