Remove hyperlink but keep text?

后端 未结 4 1381
挽巷
挽巷 2020-12-09 08:07
Mentalist

Whenever a hyperlink has a title of \"Show Profile\"

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 08:37

    Vanilla JavaScript way (instead of jQuery) to remove hyperlink but keep text:

    const links = document.querySelectorAll('a[title="Show Profile"]')
    
    links.forEach(link => {
        const el = document.createElement('span')
        el.textContent = link.textContent
        link.parentNode.replaceChild(el, link)
    })
    

提交回复
热议问题