[英]How can I stripe the HTML <b> tag and replace it with <h>?
I am using a program called anki, a SRS for learning languages.我正在使用一个名为 anki 的程序,这是一个用于学习语言的 SRS。 In anki I have a deck where 1000 cards have a code like this <b>TEXT</b>
.在 anki 中,我有一副牌,其中 1000 张卡片有这样的代码<b>TEXT</b>
。 Now I want to replace the <b>
and </b>
with <h>
and </h>
to make it look like this <h>TEXT</h>
, but I don't know how to do it.现在我想用<h>
和</h>
替换<b>
和</b>
以使其看起来像这样<h>TEXT</h>
,但我不知道该怎么做。 I tried something like this, which didn't work.我尝试了类似的方法,但没有奏效。 I would appreciate any help.我将不胜感激任何帮助。
<div id="sentence">
{{front}}
</div>
<script>
s = document.querySelector('#sentence');
s.innerHTML = s.innerHTML.replace(/.*<b>(.*)<\/b>.*/, '<p>');
</script>
You could just replace them individually:您可以单独替换它们:
s = document.querySelector('#sentence');
s.innerHTML = s.innerHTML.replace(/<b>/g, '<h>');
s.innerHTML = s.innerHTML.replace(/<\/b>/g, '</h>');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.