How to clone once with JQuery clone?

How to clone jquery-ui tabs to different loc

  • I tried to clone tabs element to different location by using clone(true) method but it didn't work properly. For example, I can not switch between tabs in '#here' div. Here is the html content: <body> <div id="tab1" class="tabs" style="height:100px; width:300px"> <ul></ul> </div> <div id="here" style="height:100px; width:300px"></div> </body> and this is the code which I tried: $('#tab1').tabs({ closable: true }); $('#tab1').tabs('add', '#' + 1, 'test'); $('#tab1').tabs('add', '#' + 2, 'test'); var tmp = $('#tab1').clone(true); tmp.appendTo($('#here')); I don't want to copy html tags and then reinitialize the tabs element like this: $('#tab1').tabs({ closable: true }); $('#tab1').tabs('add', '#' + 1, 'test'); $('#tab1').tabs('add', '#' + 2, 'test'); $('#here').html($('#tab1').html()); $('#here').tabs(); I actually want to relocate tabs, which has ui elements like jqgrid, jstree in it, to different div dynamically and the above code is not appropriate solution. thanks for your attention.

  • Answer:

    If you want to reallocate i think you could use http://api.jquery.com/detach/ so that you can reappend the elements later var tab = $('#tab1').detach(); tab.appendTo($('#here'));

Ye Adam no family at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.