Click here to Skip to main content
15,885,998 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to hide a label using jquery?
and how to hide a asp:DropdownList using Jquery?
Posted
Updated 23-May-13 23:34pm
v2

Use jQuery .hide()[^] function.
JavaScript
$('#lblId').hide(); // Replace the correct ID of Label.
$('#drpId').hide(); // Replace the correct ID of DropDown.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Jun-13 2:38am    
5ed.
—SA
Thanks a lot Sergey Alexandrovich Kryukov... :)
Hi Vasantha,

The following would do the work.

JavaScript
$('#labelID').hide();
$('#dropdownlistID').hide();


Please replace the labelID and dropdownlistId with the control IDs.
Other option is to make the css usage.

JavaScript
$('xxxxID').css('display', 'none');


Thank you,
Vamsi
 
Share this answer
 
v2
Comments
It is not show(), it is hide() to hide any selected control.
XML
document.getElementById("<%=dropdowmcontrolID.ClientID%>").style.visibility = "visible";
document.getElementById("<%=labelid.ClientID%>").style.visibility = "visible";



document.getElementById("<%=dropdownid.ClientID%>").style.visibility = "hidden";
document.getElementById("<%=labelid.ClientID%>").style.visibility = "hidden";




this is working fine..
 
Share this answer
 
Comments
Yes it will work fine. But as you said to do it using jQuery in your question, so I have posted one answer to use .hide function. It is very simple and easy.

Please accept "Solution 2" as answer.
This will help others to find the answer in one go and you will also be awarded with some points for this action...
Sergey Alexandrovich Kryukov 4-Jun-13 2:41am    
Tadish is right. You should accept his solution. And you should not post what you have here: first, you are "answering" your own question, which makes no sense (imagine how many fake posts could anyone do this way, some do, but who is interested to see it?), secondly, you are not really answering it the way you required by yourself.
—SA
Thanks... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900