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 8510079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:36:28+00:00 2026-06-11T03:36:28+00:00

I have a div with some id that contains some buttons/labels. Its a container

  • 0

I have a div with some id that contains some buttons/labels. Its a container itself. I want to have a button that when user clicks on the button a dialog has to appear with the same div but the div has to disappear from the page. So when Detach button is clicked a dialog appears with that div and button changes into Attach. When attach is clicked dialog disappears and regular div appears on the page.

This is what i tried so far, it works only when Detach is clicked, if Attach is clicked dialog closes but regular div does not show up.

   $(document).on('click', '#detach', function() {
      var button = $(this).text();
          if (button == 'Detach') {
           $('.search_div_box').dialog({ autoOpen: false, width: 700 });
           $('.search_div_box').dialog('open');
              $(this).html('Attach');
          } else if (button == 'Attach') {
             $('.search_div_box').dialog('close');
             $(this).html('Detach');
          }

      });

i know im missing a code in Attach part it only closes the dialog but i tried various things like appending to body again the div and so on but didnt work. Thank you

  • 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-06-11T03:36:30+00:00Added an answer on June 11, 2026 at 3:36 am

    You could use jQuery’s $.clone() to create a duplicate of the div and then show/hide it along with the dialog like this:

    var $original = $('.search_div_box');
    var $clone = $('.search_div_box').clone();
        $clone.dialog({
                autoOpen: false,
                width: 700,
            });
    
    $(document).on('click', '#detach', function() {
        var button = $(this).text();
    
        if (button == 'Detach') {
            $original.hide();
            $clone.dialog('open');
    
            $(this).html('Attach');
        } else if (button == 'Attach') {
            $original.show();
            $clone.dialog('close');
    
            $(this).html('Detach');
        }
    });​
    

    JSFiddle Here

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

Sidebar

Related Questions

I have a DIV that contains some buttons (divs) each button is set to
I have a div that contains within itself logout button and username. If the
I have a div with id=images. The div contains some images that are each
I have a div that contains a couple of radio buttons. These show/hide a
I have ASCX control, that basically contains just a DIV with few ASP buttons
I have Div that it contains some other elements like <p> , <ul> ,...
I have a div with some content that has a negative position relative. I
I have a div with some inner content that I need to have an
I have a div (sub area of page with scroll bar) that has some
I have created some JQuery that will expand a div 'popup' on hover and

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.