clone - jQuery Cloning Parent Element -


i'm wanting clone parent element. i've managed clone contents of element.

$(this).parents('.row').clone(); 

this returns contents of .row, how may clone .row element?

fiddle - give last input value

what don't include you're using .html() in jsbin code, what's returning inner part of row.

to "combat" this, use temporary container , .html() on container:

$('<div>').append($(this).parents('.row').clone()).html(); 

http://jsbin.com/fesicaqotu/1/edit?js,output

another, perhaps better option, use .outerhtml on dom element , forget clone altogether:

self.parents('.row')[0].outerhtml; 

http://jsbin.com/buhekitiju/2/edit?js,output


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -