最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to remove anchor tag text using Javascript - Stack Overflow

programmeradmin2浏览0评论

How to remove the anchor tag text and href link using javascript Or Jquery

<a id="ancID" href="Javascript:void(0)">Here insert a dynamic text </a>

I want to remove the text inserted between anchor tag..

How to remove the anchor tag text and href link using javascript Or Jquery

<a id="ancID" href="Javascript:void(0)">Here insert a dynamic text </a>

I want to remove the text inserted between anchor tag..

Share Improve this question asked Dec 17, 2013 at 6:39 bgsbgs 3,2237 gold badges42 silver badges59 bronze badges 1
  • using javascript regex can anyone help? – yaswanthkoneri Commented Nov 26, 2019 at 13:23
Add a ment  | 

2 Answers 2

Reset to default 4

You can use .text('') to remove text by assigning empty string. First use id selector to get the anchor tag.

Live Demo

$('#ancID').text('');

If you go the vanilla way:

var x = document.getElementById("ancID");
x.innerHTML = "";
x.href = "";
发布评论

评论列表(0)

  1. 暂无评论