gpt4 book ai didi

Jquery 正则表达式 : substitute

转载 作者:行者123 更新时间:2023-12-01 06:58:56 24 4
gpt4 key购买 nike


这是我的代码:

$(".tooltip").live('click', function() {
var texte = $('#tiptip_content').text();
$('#subheader').html(texte);
});

var texte包含一些文本 <br/>标签和 <b></b>标签。
我想将此文本添加到 #subheader 但使用 <br/>更改为“双空格”和 <b></b>标签已删除。

请问我该怎么做?

最佳答案

至于非正则表达式解决方案。

.text()删除任何 <elements/>您可以使用.replaceWith()更改您的 <br/>&nbsp;&nbsp;

var d = $('#tiptip_content').clone();
var texte = d.find("br").replaceWith("&nbsp;&nbsp;").end().text();
$('#subheader').html(texte);

<强> Example on jsfiddle

关于Jquery 正则表达式 : substitute <br/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5978076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com