I am creating a jQuery plugin to manage form collections. The plugin aims to add the add , remove , move up and move down buttons to modify this collection.
The root of the node collection always contains a selector, for example .collection .
A button can be any as soon as it has a .add class
I implemented the min and max options, so the add and remove buttons disappear accordingly. My problem arises when I try to manage a collection of form collections: how do I select only add buttons that link to the desired collection?
To simplify the task, check out the following HTML code:
<div class="collection"> <div>something</div> <div>something</div> <div> <div class="add">+</div> </div> <div>something</div> <div class="collection"> <div>something</div> <div>something</div> <div> <div class="add">+</div> </div> <div>something</div> </div> </div>
Keep in mind that a button can be arbitrary: the assembly is created by the user, and I donβt know where the button can be in dom. By the way, this is deeper than .collection , which is all I know.
How to select all add buttons before the second .collection , but no more?
For those interested, this plugin is available (but in active dev) here .
javascript jquery html forms formcollection
Alain tiemblo
source share