Use .innerHTML
or .innerText
document.getElementById("tagId").innerHTML="new File",
OR
document.getElementById("tagId").innerText="new File",
OR
Note: Not all browsers support innerTEXT
, so use textContent
if you want to change the text only,
Reference Stack overflow answer
So like @Amith Joki said, use like
document.getElementById("tagId").textContent="new File",
Since <a>
tag doesn't have value property, you need change the html of anchor tags.
Using Jquery
$("#tagId").html("new File");
OR
$("#tagId").text("new File");
Edit
If you want to change the href using javascript, USe like this
document.getElementById("tagId").href="new href";
USing jquery,
$("#tagid").attr("href","new value");