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

  • Home
  • SEARCH
  • 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 6037001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:00:32+00:00 2026-05-23T06:00:32+00:00

In this jsFiddle http://jsfiddle.net/littlesandra88/RBU8K/ have I the following code function addRemove(id) { alert(1); $(‘#’+id).toggle(function()

  • 0

In this jsFiddle

http://jsfiddle.net/littlesandra88/RBU8K/

have I the following code

function addRemove(id) {
    alert("1");

    $('#'+id).toggle(function() {
    alert("2");
    $('#'+id).after('<tr id="details" ><td>It worked</td></tr>');

    }, function() {
    alert("3");
    $("#details").remove();    
    });
}

When clicking one time on “Details” it prints “1”, but not “2” for some reason.

When the first click have been done, it works like it is supposed to.

But what’s wrong, since the first click doesn’t print out “2”?

And how can it be fixed?

Update

This is the solution

function addRemove(id) {

    if ($('#accTable').find("[id*='details']").length == 0) {   
    $('#'+id).after('<tr id="details" ><td>It worked</td></tr>');
    } else {
    $("table tr").remove("#details");
    }

}
  • 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-23T06:00:33+00:00Added an answer on May 23, 2026 at 6:00 am

    You are only attaching a event handler (the toggle thingy) when calling addRemove(), then after you click again the event handler gets triggered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple code like this http://jsfiddle.net/9braK/2/ $(function(){ $('body').append( $("<a/>").attr({ "id": "foo", "href":"#"
Here is a live example of my problem http://jsfiddle.net/littlesandra88/xksB9/ I would have expected that
I have a div like this: http://jsfiddle.net/ANvpS/ . How can I highlight every other
As illustrated in this jsfiddle: http://jsfiddle.net/qrbhb/ If you take this markup: <div>There should be
Please see this http://jsfiddle.net/yv8uw/1/ When you click View all Comments the box opens up
I want to make a menu that.. does this: http://jsfiddle.net/8U9fy/1/ ( didnt want to
With this code: <ul data-role=listview id=routelist data-theme=g> <li id=firstlistitem style=display:none;> $(<li><a href='http://www.google.co.uk'></a></li>).text('content').insertAfter($(#firstlistitem)); and see
I've been mucking around with this jsfiddle code but can't get it to do
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
This is a bit of a long shot, but if anyone can figure it

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.