再做項目的時候需要給文本里的含http或者https://開頭的都自動加上鍊接 所以就寫了一個正則
var string = "http://www.tianji.com https://www.tianji.com dfdfd"
var str = string.replace(/(https?:\/\/\S+)/g,"<a href='$1' target='_blank'>$1</a>"),
再做項目的時候需要給文本里的含http或者https://開頭的都自動加上鍊接 所以就寫了一個正則
var string = "http://www.tianji.com https://www.tianji.com dfdfd"
var str = string.replace(/(https?:\/\/\S+)/g,"<a href='$1' target='_blank'>$1</a>"),
(function(d, s, id) { let js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) retur