将 jquery 文本替换为 TM 字符实体,并用 jquery 替换

Replace jquery text with TM character entity, with jquery

本文关键字:jquery 并用 替换 实体 TM 文本替换 字符      更新时间:2023-09-26

如何使用jquery更改文本中带有TM字符实体的文本?

例如:

TM = &#8482 ; ™

<h1>Some text&#8482;</h1>

现在我想将按钮单击时的文本更改为"这是其他文本™"

$('#click1').on('touchend', function () {
    $('h1').text("This is some other text");
});

如何使用 jquery 放置它™以及如何将其放置在<sup></sup>中?

试试这个

$('h1').html("This is some other text <sup>&#8482;</sup>");

使用 .html 而不是 .text

$('h1').html('This is some other text &#8482;');