neha dhage
neha dhage

Reputation: 1

How to hide a label using Javascript?

Using Javascript, how do you make a label invisible on a button click?

Upvotes: 0

Views: 12212

Answers (3)

ajay_whiz
ajay_whiz

Reputation: 17951

A label is rendered as span tag in HTML. If you know the id of any the control you can turn off its visibility through JavaScript by

document.getElementById('your-element-id').style.display='none';

Upvotes: 0

naikus
naikus

Reputation: 24472

I'm not sure what you want but here goes:

<label id="mylabel">Woot!!</label>

button.onclick = function() {
  document.getElementById("mylabel").style.display = "none";
}

Upvotes: 2

amaseuk
amaseuk

Reputation: 2155

Just from the top of my head

<input type="button" onclick="document.getElementById('labelname').style.display = 'none';" />

Upvotes: 0

Related Questions