我想在我的内容区域找到所有的时间码,并围绕它建立一个简单的链接,这样我就可以跳转到我的Wordpress Mediaelement上的特定时间码。
我怎么做才能让它看起来像这样:
<div class="timecodes">
<li>
**<a class="go-to-time">**15:30**</a>** "Title"
</li>
</div>发布于 2016-01-01 20:15:22
我自己想出来了,这是我的解决方案:
var str=document.getElementById("timecodes").innerHTML;
var n=str.replace(/[0-9][0-9][:][0-9][0-9]/gi,function myFunction(x){return "<a class='go-to-time'>" + x + "</a>";});
document.getElementById("timecodes").innerHTML=n;https://stackoverflow.com/questions/34545539
复制相似问题