gpt4 book ai didi

jquery - 使用 jQuery 在文本的特定部分之前添加

转载 作者:搜寻专家 更新时间:2023-10-31 02:25:48 26 4
gpt4 key购买 nike

我有 2 个这样的段落:

<p>text bla bla bla owner of the idea : John Smith</p>
<p>text bla bla bla bla bla bla owner of the idea : James Marino</p>

有什么方法可以使用 jQuery 在“Owner of the idea”之前添加一个新行直到句子结束?

提前致谢

最佳答案

如果这是您的 jquery 脚本的副本,请尝试使用 \n 换行。这在 javascripts 中有效。

jQuery 工作示例:

 <p id="s">text bla bla bla owner of the idea : John Smith</p>
<p>text bla bla bla bla bla bla owner of the idea : James Marino</p>

<script type="text/javascript">
$(document).ready(function() {
$("p").each(function() {
var getContent=$(this).text();
var newString=getContent.replace('owner of the idea','<br />owner of the idea');
$(this).html(newString);
});
});
</script>

关于jquery - 使用 jQuery 在文本的特定部分之前添加 <br/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6379538/

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