Jquery-Clone() append -
I am facing a problem that is trying to clone a parent unit and after that My self is directly involved, my job works fine until the last node is selected:
The result of
If I clone a. But if I clone one again
& lt; Div & gt; & Lt; Div & gt; A & lt; / Div & gt; & Lt; Div & gt; A1 & lt; / Div & gt; & Lt; Div & gt; A & lt; / Div & gt; & Lt; Div & gt; A1 & lt; / Div & gt; & Lt; Div & gt; B & lt; / Div & gt; & Lt; Div & gt; C & lt; / Div & gt; & Lt; / Div & gt;
I like
& lt; Div & gt; & Lt; Div & gt; A & lt; / Div & gt; & Lt; Div & gt; A1 & lt; / Div & gt; & Lt; Div & gt; A1 & lt; / Div & gt; & Lt; Div & gt; B & lt; / Div & gt; & Lt; Div & gt; C & lt; / Div & gt; & Lt; / Div & gt;
My markup and code are below:
& lt; Div id = "maindiv" & gt; & Lt; Div & gt; & Lt; Label & gt; First & lt; / Labels & gt; & Lt; Input type = "button" class = "repeat1" onclick = "repeat (this)" /> & Lt; / Div & gt; & Lt; Div & gt; & Lt; Label & gt; Second & lt; / Labels & gt; & Lt; Input type = "button" class = "repeat1" onclick = "repeat (this)" /> & Lt; / Div & gt; & Lt; Div & gt; & Lt; Label & gt; Third & lt; / Labels & gt; & Lt; Input type = "button" class = "repeat 2" onclick = "repeat (this)" /> & Lt; / Div & gt; & Lt; / Div & gt; Repeat the function (obje) {var present = $ (obj) .parients ("divis [class ^ = 'repeat']: first"); $ (CurrentDiv) .clone () appendTo (CurrentDiv) .end () .; }
I have a similar problem where all the nodes have been removed, while a single div has been removed from me. Any help would be appreciated. Remove function is
Remove function (obj) {var CurrentDiv = $ (obj) .parents ("div [class ^ = 'repeat']: first"); CurrentDiv.remove (); }
What are you trying to do?
Repeat the function (obj) {var currentDiv = $ (obj). Parent ("div"); . CurrentDiv.clone () insertAfter (currentDiv); } Update: If you want nesting, try: & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Ul & gt; Second & lt; Li & gt; & Lt; Label & gt; Sub-second & lt; / Labels & gt; & Lt; Input type = "button" class = "repeat1" onclick = "repeat (this)" /> & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Ul & gt; Third & lt; Li & gt; & Lt; Label & gt; Sub-thirds & lt; / Labels & gt; & Lt; Input type = "button" class = "repeat 2" onclick = "repeat (this)" /> & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Script & gt; Repeat the function (obj) {var current = $ (obj). Parent ("li"); . CurrentLi.clone () insertAfter (CurrentLi); } & Lt; / Script & gt;
Comments
Post a Comment