已关闭。此问题需要更多focused。目前不接受回答。
**要改进此问题吗?**更新此问题,使其仅针对editing this post的一个问题。
13天前关门了。
Improve this question的
我有一个包含从Wix Studio输出的html的字符串。我试图操作并放回原始标签中。到目前为止,我已经设法剥离标签并操作字符串(将每个字母用a Package 起来),但我不知道如何将被操纵的字符串(内部)放回原始标记中,下面是预期的结果。不会总是<h1>
,可能是<h2>
到<h6>
,可能是<p>
-无法使用jQuery!
// Get string from Wix using the Wix Editor Elements ($w) APIs)
var html = $w('Text').html;
var string = html.replace(/(<([^>]+)>)/ig, ''),
wrap = string.replace(/\w/g, "<span>$&</span>");
字符串html
返回"<h1 class="wixui-rich-text__text">Add a Title</h1>"
全部正常string
返回"Add a Title"
全部正常wrap
返回"<span>A</span><span>d</span><span>d</span> <span>a</span> <span>T</span><span>i</span><span>t</span><span>l</span><span>e</span>"
全部正常
期望结果:
原始的html标签,其中包含修改后的内容:output
返回"<h1 class="wixui-rich-text__text"><span>A</span><span>d</span><span>d</span> <span>a</span> <span>T</span><span>i</span><span>t</span><span>l</span><span>e</span></h1>"
有点超出我的深度,也许是一个更好的方式去。
多谢了!
参考编号:https://www.wix.com/velo/reference/$w/text/html
2条答案
按热度按时间zwghvu4y1#
我认为这将满足您的需求:
字符串
测试输入字符串:
型
输出字符串:
型
nxagd54h2#
更好的方法是将其解析为DOM并对其进行操作
字符串