Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all
i am using a label in inside a div
ASP.NET
<div id="popupCon"  runat="server" 
        style=" position: fixed; background-color: Black; height: 100%; width: 100%;">
        <br />
        <asp:Label ID="Label1" ForeColor="white" runat="server" Text="Label"></asp:Label>
</div>

and by using jquery i want to set opacity of div if label1 has value of 1
JavaScript
<script type="text/javascript">
 //$(document).ready(function() {
       if("#Label1"=="1"){
       $("#popupCon").css({
           "opacity": "0.7"
       });
      }

   </script>


but i could not figure it out can any one guide me through
thanks
Posted

Try This
C#
<script type="text/javascript">
  //$(document).ready(function() {
        if($("#Label1").val()=="1"){
		$("#popupCon").css({
			"opacity": "0.7"
		});
       }
       
    </script>
 
Share this answer
 
v2
Comments
mehdilahori 30-May-12 3:01am    
i used this but nothing happened
tanweer 30-May-12 3:21am    
hey dear sunandandutt, Label does not has val property, it has only html() property, please correct your answer
You should start by reading this article[^].
This[^] could help you too.
 
Share this answer
 
v2
try like this

JavaScript
<script type="text/javascript">
  //$(document).ready(function() {
        if($("#Label1").html()=="1"){
		$("#popupCon").css("opacity","0.7");
       }       
    </script></script>

but remember if you are using master page then the IDs for popupCon and Label1 may be different, like ctl00_ContentBody_Label1 etc, please confirm and use.
 
Share this answer
 
v2
Comments
mehdilahori 30-May-12 3:48am    
hi tanweer
that also did mot work i thought that would be very simple actually i want to use label just as a flag variable
any other alternative would be deeply appreciated
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