gpt4 book ai didi

javascript - 实时向对话气泡添加文本

转载 作者:行者123 更新时间:2023-11-28 13:20:29 24 4
gpt4 key购买 nike

我有一个图像将构成 html 页面的背景,我想在其上叠加气泡。我已经想出如何用 CSS 制作气泡,并设置它们的位置。但我不知道如何填充气泡(div 元素)。文本消息将填充文件,我需要获取字符串并将它们显示在气泡中,并在收到消息时刷新气泡内容。有什么想法吗?

最佳答案

假设您的其中一个气泡包含如下所示的 DIV:

<div id="bubble1">This is the text</div>

您可以使用 Javascript 轻松更改文本内容。建议使用像 jQuery 这样的 JS 库。这是一个更改文本的代码示例:

<script>

$(document).ready(function()
{
$('#bubble1').text('This is the changed text'); // to change the text
$('#bubble1').html('This has <b>some</b> formatting'); // to change the html
});

</script>

不要忘记用一行代码包含 jQuery 本身:

<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

我不明白你从哪里得到你的字符串,如果你让我知道,我可以更新答案。

如果你不熟悉jQuery,看看here .

关于javascript - 实时向对话气泡添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14671113/

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