Someone will be able to explain on the fingers and the example of the code how to replace one dom-element with another.

There is a code:

<td id="18"><div class="label"></div> текст</td> <td id="22"><div class="label"></div> тут тоже текст</td> <div class="pp"> <div class="label" id="3"></div> <div class="label" id="4"></div> </div> 

By clicking on div.label, div.pp pops up, and when you click on one of the divs inside div.pp, this div should replace the div inside the td cell, on which the div.pp was called. Replacement should occur by cloning - this is the time, and it is not the text inside div.label that needs to be replaced, but the object itself.

I will not catch up on how it is done. Can someone tell me?

    1 answer 1

    Will help you replaceWith () .

    • Yes, yes, I have already figured out, so always, for a couple of hours I am tormented by the problem, I am writing here, and as soon as I wrote, I immediately find a solution :). That's just another problem appeared. After the replacement, clicking on the replaced element no longer causes div.pp. Only I did with replaceAll (), with replaceWith () something did not work - DemoS
    • Hang the event not $('table .label').click(...) , but $('table .label').live('click', ...) . - ling
    • Yes, and did, but something did not work. Just apparently js did not want to be updated in the cache. Now everything is ok, Thank you! - DemoS