Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi..

i have created dynamic div in jquery...now onbutton click event i want to make visible false of this div...how do i get id of this div in jquery & make this div visible false???

please help me out...
Posted

1 solution

Hi Try this code..

XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="POC.WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="JQuery.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(function () {

            $('<div id="mydiv"></div>').css({ 'height': '100px', 'width': '100px', 'background-color': 'green' }).appendTo('#form1');

            $('#btnhide').click(function () {
                $('#mydiv').hide('slow'); return false;
            });
            $('#btnshow').click(function () {
                $('#mydiv').show('slow'); return false;
            });

        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="btnhide" runat="server" Text="Hide" />
     <asp:Button ID="btnshow" runat="server" Text="Show" />
    </form>
</body>
</html>
 
Share this answer
 
Comments
Member 10276220 2-Dec-13 5:19am    
this is not working..
Karthik_Mahalingam 2-Dec-13 5:29am    
did u add jquery reference to it ???

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