Jump to content

jquery .clone its use


cve60069
 Share

Recommended Posts

hello I am trying to add a line to a document and edit its contents. I have used jquery clone method (attached). I want to create just one line. i know why I am going wrong but I do not know how to solve. I think it is the ".append($('.item')", This needs to be ".append($('last cloned item')" - maybe. Any hints would be appreciated Regards

paragraph.html

Link to comment
Share on other sites

Using .item is going to target everything with the class item. Maybe you should use ID instead, or use DOM methods to get that node. With that structure it is the second child of the body, so you can target it with document.getElementsByTagName('body')[0].childNodes[1]. Note that appending to the item is going to put one div inside the other one, not next to each other. If you want them next to each other then you need to append the new element to the body, not the div.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...