gpt4 book ai didi

javascript - 使用 jquery 预览文本

转载 作者:行者123 更新时间:2023-11-30 10:49:09 24 4
gpt4 key购买 nike

我有以下html

<img src="a.jpg" /><p> This is some random text and just to test this example. This is some random text and just to test this example. This is some random text and just to test this example<p>
<br><p>This is some random text and just to test this example This is some random text and just to test this example</p>
<img src="a.jpg" />
<br><p>This is some random text and just to test this example This is some random text and just to test this example</p>

我的问题是,如果我必须只使用 jquery 来预览文本,假设我在名为 html 的变量中有这个,如何只显示文本的少数部分而忽略图像

       <div id="preview"></div>
$("#preview").val("//display only text in the variable named html")

最佳答案

你可以 filter图片来自 html:

var someHtml = '....';
$('#preview').html($(someHtml).filter(':not("img")'));

关于javascript - 使用 jquery 预览文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6544528/

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