我想知道如果文本周围有标记(比如不和谐的消息),是否可以更改文本样式
我的方法是首先获取页面中(通常)包含文本的所有元素
const getTagName = (x) => document.getElementByTagName(x);
let p = getTagName("p");
let h1 = getTagName("h1");
let h2 = getTagName("h2");
let h3 = getTagName("h3");
let h4 = getTagName("h4");
let h5 = getTagName("h5");
let h6 = getTagName("h6");
//there are probbably much more text-containing-elements, but for here i dont really care
然后我会浏览它们,找到例如“**”。。。“**”并将内容放入
<span style="font-weight: 900">\</span>
要素
我的问题是:我看不出有什么“常用”的方法可以做到这一点。有人能帮忙吗?