使用jQuery;替换时添加跨度类别时添加跨度类功能

发布于 2025-02-12 05:28:45 字数 318 浏览 0 评论 0原文

我认为我的问题很容易解决,但我没有找到与此相关的任何问题。我只想在使用jQuery替换时添加类ID。

在这里,我正在使用这个小脚本:

<script>
  $("body").html($("body").html().replace(" <strong>Mario</strong> game" , " <span class="class-id"><strong> Mario</strong> bros."));
  </script>

您能帮我吗?谢谢

I think my problem is simple to resolve but i didn't find anything related to this. I just want to add a class id when i use JQuery replace.

Here i'm using this small script :

<script>
  $("body").html($("body").html().replace(" <strong>Mario</strong> game" , " <span class="class-id"><strong> Mario</strong> bros."));
  </script>

Can you help me? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠北森屋 2025-02-19 05:28:45

示例

  $("body").replaceWith("<span class='red'><strong> Mario</strong> bros.");

在这里呢:
https://codepen.io/polinq/polinq/pen/pen/yllknggv?editors=1111111111111111111111111111111111111111

what about

  $("body").replaceWith("<span class='red'><strong> Mario</strong> bros.");

Example here:
https://codepen.io/polinq/pen/yLKNggV?editors=1111

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文