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 ?
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>
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.
You can do this many ways. Here are 5 ways Id do it, and 2 methods using jQuery are included.
$('[for="Some Feild"]').css('display','none');
$('[for="Some Feild"]').fadeOut();
document.getElementById(myID).style.display = "none";
[for="Some Feild"] {display:none}
Some Text
All of the above will hide the span.
- This is the jQuery method of changing the CSS
- This way jQuery will fade out your span for a nice effect.
- This is the raw JS method, however, you need to add an ID to your label for it to work
- This is the CSS to change it in tags or in an external style sheet.
- This is the quick and dirty way of doing it with CSS.
精彩评论