将字符串封闭在< span>标签
我想将“ 课程”更改为“ 歌曲”,因为22 的 0 动态价值会在某人单击按钮时会增加。我已经尝试了此代码,但没有增加数字:
setInterval(() => {
if ($('#completion-count').length && !$('.completion_count_no_repeat').length) {
$('#completion-count').empty();
$("#completion-count").append(`<span id="completion-count" class="font-semibold">0 of 22 Songs Completed</span>`);
}
}, 1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span id="completion-count" class="font-semibold">0 of 22 Lessons Completed</span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有增加数字。
您需要保持最后数字的数量,然后将其格式化为字符串:
字符串中的卷曲牙套用于模板。 ()
You are not incrementing the number.
You need to keep count of the last number and then format it into the string:
The curly braces in the string are for templating. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)