本帖最后由 pzx521521 于 2020-11-5 17:09 编辑
你写的就是第一个哦
[Asm] 纯文本查看 复制代码 var html=document.getElementsByClassName("ciyu")[0]
[0]就是第一个的意思
这样修改:
[HTML] 纯文本查看 复制代码
<div class="content">
<div class="ciyu">「點解」 解釋 #1<br />讀音:dim2 gaai2 <br />詞性:代詞 出处:某度<br />解釋:(廣東話) 用嚟問原因、理由嘅疑問代詞;何解;乜#解究 (英文) why; how
come <br />例句:(粵) 你上個星期日點解唔嚟嘅? (nei5 soeng6 go3 sing1 kei4 jat6 dim2 gaai2 m4 lai4 ge2?) (英) Why didn't you come
last Sunday? (粵) 點解你幾時都on住line,好似唔使瞓噉嘅? (dim2 gaai2 nei5 gei2 si4 dou1 on1 zyu6 laai1, hou2 ci5 m4 sai2 fan3 gam2
ge2?) (英) Why are you online all the time, like you don't need to sleep? 电话: </div>
<div class="ciyu">「刻板」 <br />解釋 #1 讀音:haak1 baan2 ,hak1 baan2 <br />詞性:形容詞</div>
<script>
let ciyus = document.getElementsByClassName("ciyu")
for (var i = 0; i < ciyus.length; i++) {
ciyu = ciyus[i]
var html = ciyu.innerHTML;
html = html.replace("解釋 #1", "<i>解釋 #1</i>").replace("讀音:", " <span class='a'>讀音:").replace("<br>詞性:",
"</span> <br>詞性:").replace("出处:", "<br/>来源:").replace("电话:", "");
ciyu.innerHTML = html;
}
</script>
</div>
|