I have to do some forms and generate div with them but that's not my problem here.
Actually, I would like to know how create something like a hierarchy between this generated div, and the main actor will be the <select> tag.
Here is an image of what I would like to have. For exemple when I create a chapter and I related it to the Book 1 I just generated before, then the chapter append inside the right "book" div. Or another example if I want to create a specific Line block. I want it in the right Chapter block itself in the right Book block.
IDs must be unique within your document, so you can't generate multiple elements with ID "BookName" for example. Use a class instead to apply the appropriate styling.
You can use the data function to store information against an element. So you could create the new book/chapter/line and append it to the DOM, then store a reference to that element against the new option that is created for the drop-down. In the future when you create a sub-element for that one, you can retrieve the reference from the selected drop-down option and use that to insert the new item in the correct place.
Leave a comment on kbwood.au's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic