[英]Injecting newline after specific word in text with tritium
I have a span node that needs a newline inserted after a certain word. 我有一个span节点,需要在某个单词后插入换行符。 Whenever I use tritium to get into the inner() or text() scope I can't figure out how to inject a break in a way that the browser will interpret as a new node and not text.
每当我使用tri进入inner()或text()范围时,我都无法弄清楚如何以浏览器将其解释为新节点而不是文本的方式注入中断。 I don't want to grab the first half as a var and put them in a new node, is there an easier way to do this?
我不想将前半部分作为var并将其放在新节点中,是否有更简单的方法来做到这一点?
This code should work: You might also want to wrap the 这段代码应该可以正常工作:您可能还需要包装
$("xpath") {
inner() {
replace(/(regex)/, '<br /> $1')
# This will work also:
# replace(/(regex)/, '<span class="mw-block">$1</span>'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.