Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7691929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:44:08+00:00 2026-05-31T20:44:08+00:00

I am trying to hide/show/toggle a div when a button is clicked. I am

  • 0

I am trying to hide/show/toggle a div when a button is clicked. I am using ASP.NET and everything is inside an ASP:Datalist.

I can show or hide the div correctly. However it opens all the divs instead of just the one where the button was selected. The div is am trying to show/hide is .content

How can I open only the div that the button belongs?

JSFiddle – here’s an example of the problem http://jsfiddle.net/kMEre/

The script:

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery(".content").hide();
    });
</script>
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('#man').live('click', function (event) {
           jQuery('.content').toggle('show');
        });
    });
</script> 

The datalist (ASP.NET)

<asp:DataList runat="server" id="dgQuestionnaire" DataKeyField="QuestionID" >
    <ItemTemplate>
        <div class="question_box">
            <p class="small_bold">Question <asp:Label ID="lblOrder" runat="server" Text='<%# Container.ItemIndex  + 1 %>'></asp:Label></p>
            <div class="Questions">
               <div class="heading">
                   <asp:HiddenField ID="hiddenQuestionID" runat="server" Value='<%# Eval("QuestionID") %>' />
                   <asp:TextBox runat="server" ID="tbQuestionName" Text='<%# Eval("QuestionText") %>' CssClass="form" Width="300px"></asp:TextBox>
                   <input type='button' id='man' value='hide/show'>
               </div> <!-- end heading -->
               <div class="content">
                  <p class="small_bold new">Question Type</p>
                  <asp:DropDownList runat="server"  ID="QuestnType" CssClass="question_dropdown">
                  <asp:ListItem Value="1">Check Boxes (Multiple Choice)</asp:ListItem>
                  <asp:ListItem Value="2">Drop Down</asp:ListItem>
                  <asp:ListItem Value="3">Open Ended</asp:ListItem>
                  <asp:ListItem Value="4">Radio Buttons (Single Choice)</asp:ListItem>
                  <asp:ListItem Value="5">Range (Percentage)</asp:ListItem>
                  </asp:DropDownList>
                  <asp:DataList ID="nestedDataList" runat="server">
                     <ItemTemplate>
                         <p class="new">Answer <asp:Label ID="lblAnswerOrder" runat="server" Text='<%# Container.ItemIndex  + 1 %>'></asp:Label></p>
                         <asp:HiddenField ID="hiddenAnswerID" runat="server" Value='<%# Eval("AnswerID") %>' />
                         <asp:TextBox ID="TextBox1" runat="server" CssClass="form" Text='<%# Eval("AnswerID") %>' Width="300px"></asp:TextBox>
                         <asp:TextBox ID="tbAnswerText" runat="server" CssClass="form" Text='<%# Eval("AnswerTitle") %>' Width="300px"></asp:TextBox>
                     </ItemTemplate>
                 </asp:DataList>
                 <asp:Button runat="server" ID="updateName" CssClass="button_update" style="border: 0px;" onClick="UpdateQuestionName_Click" />
                 <asp:Button runat="server" ID="btnDelete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this question?');" />
             </div>
         </div> <!-- end Questions -->
      </div> <!-- end questionbox -->
      <script type="text/javascript">
          jQuery(document).ready(function () {
              jQuery(".content").hide();
          });
      </script>
      <script type="text/javascript">
          jQuery(document).ready(function () {
              jQuery('#man').live('click', function (event) {
                  jQuery('.content').toggle('show');
              });
          });
      </script>   
  </ItemTemplate> 

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:44:09+00:00Added an answer on May 31, 2026 at 8:44 pm

    try this:

    jQuery(document).ready(function () {
            jQuery('#man').live('click', function (event) {
               $(this).closest('.heading').next().toggle('show');
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a button to show / hide a div below it,
Trying to make a simple toggle menu, and I can't seem to hide/show the
I´m new developing on .net and using jquery. I´m trying to hide/show a dropdownlist
I'm trying to toggle (hide/show) a table when clicking a button which is located
Hi I have been trying to make a show/hide toggle button with jquery but
I'm trying to make a toggle button (F) to hide or show my chat
I am trying to show/hide a users twitter feed when the icon is clicked
I'm trying to create a standardized show/hide element system, like so: <div class=opener popup_1>Click
I am trying to show and hide an inline element (eg a span) using
I am trying to hide the button based on the user's role using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.