admin管理员组

文章数量:1391943

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 = "";

本文标签: jqueryHow to remove anchor tag text using JavascriptStack Overflow