tags:

views:

35

answers:

3

i am using a label

<asp:Label ID="lblMessage" runat="server" Text="" BorderStyle="Solid"></asp:Label>

in script part iam doing something

$('span[id$=lblMessage]').click(function()
    {
        $('#lblMessage').hide(slow);
    });

but it is not working

+1  A: 

Have you surrounded by $(document).ready?

$(document).ready(function(){
    $("#<%= lblMessage.ClientID %>").click(function() {
        $(this).hide("slow");
    });
});

An alternative is to use a class selector. That way, you don't limit yourself to a single hideable label. You can hide anything that has this class.

<asp:Label ID="lblMessage" cssClass="hideable" runat="server" Text="" BorderStyle="Solid"></asp:Label>

$(document).ready(function(){
    $(".hideable").click(function() {
        $(this).hide("slow");
    });
});
Daniel Dyson
+3  A: 

this should work, you should enclose the slow with quote

$(document).ready(function(){
    $("#<%= lblMessage.ClientID %>").click(function() {
        $(this).hide("slow");
    }); 
});
rob waminal
Very good point. I have updated my answer to reflect as well. I will upvote bt I have reached my daily limit today.
Daniel Dyson
A: 
function pageLoad(sender, args)
    {
        $('#<%=lblMessage.ClientID %>').click(function()
        {
            $(this).fadeOut('slow');
        });
    }

now its working fine

Mac