Sonam Mohite
Sonam Mohite

Reputation: 903

How to show a div when Click on text box in asp.net. using jquery

I tried like this

<script type="text/javascript">
$(document).ready(function () {
$('#divID').hide();
 $('#txtInsertComments').Onfocus(function () {
 $('#divID').show();    });
});
</script>


//Asp.net Design
  <asp:TextBox ID="txtInsertComments" runat="server" Text="Demo"></asp:TextBox>
   <div runat="server" id="divID">
This is Div
</div>

but still not working... please help me out ...

Upvotes: 2

Views: 2077

Answers (1)

Priyank Patel
Priyank Patel

Reputation: 6996

If you are using this with Master Page then the ID of your Textbox will change.So use this.

$('<%txtInsertComments.ClientID%>').focus(function () {
     $('#divID').show();    });
    });

If you are not using Master Page then this should work

$('#txtInsertComments.ClientID').focus(function () {
         $('#divID').show();    });
        });

Upvotes: 1

Related Questions