I have the following hidden <p> element in the body tag of my HTML file (for my chrome extension).
<p hidden id="button">
<a id="dashboard-btn" href="www.google.com" target="_blank" rel="noopener noreferrer">
www.google.com
</a>
</p>
I want to unhide this using JavaScript. My random try that failed to unhide it:
document.getElementById("button").style.visibility = 'visible';
[SOLVED] This (also) worked:
document.getElementById("button").style.display = "block";
You can use removeAttribute
document.getElementById("button").removeAttribute('hidden')
<p hidden id="button">
<a id="dashboard-btn"
href="www.google.com"
target="_blank"
rel="noopener noreferrer">
www.google.com
</a>
</p>
You hide your element with attribute hidden so you need to control that attribute instead of style like:
document.getElementById("button").hidden = false;
<p hidden id="button">
<a id="dashboard-btn" href="www.google.com" target="_blank" rel="noopener noreferrer">
www.google.com
</a>
</p>
Reference:
Try with this
document.getElementById("button").removeAttribute("hidden")