tags:

views:

16

answers:

3

Hi,

I have a label like

<label for="Some Feild" >Some Text </label>

Now I want to set the style of display of this label to none

How can I do this ?

+1  A: 

Give it an id, then do:

document.getElementById(myLabelId).style.display = "none";

Or, if you didn't mean "by javascript" :

<label for="Some Feild" style="display:none" >Some Text </label>
Alsciende
That was my solution, but I am afraid I do not know why the title of the question has the word *remove* in it.
Anthony Forloney
+1  A: 

give id to the label tag as <label for="Some Feild" id="someLabel" >Some Text </label> and then document.getElementById(myLabelId).removeChild(); would remove inner content of that label.

A: 

You can do this many ways. Here are 5 ways Id do it, and 2 methods using jQuery are included.

  1. $('[for="Some Feild"]').css('display','none');
  2. $('[for="Some Feild"]').fadeOut();
  3. document.getElementById(myID).style.display = "none";
  4. [for="Some Feild"] {display:none}
  5. Some Text

All of the above will hide the span.

  1. This is the jQuery method of changing the CSS
  2. This way jQuery will fade out your span for a nice effect.
  3. This is the raw JS method, however, you need to add an ID to your label for it to work
  4. This is the CSS to change it in tags or in an external style sheet.
  5. This is the quick and dirty way of doing it with CSS.
Oscar Godson