How to choose a child and then parent .appendTo()?

Guys, decided to make a couple animated checkboxes, but I can't make jquery condition.

Need if the child has a data-mod="m1" , parent $(переменная_1).appendTo()
If the child has a data-mod="m2", parent $(переменная_2).appendTo()

And I have one variable is substituted for all elements

The sample code here
June 4th 19 at 16:44
1 answer
June 4th 19 at 16:46
Solution
$('.mod__input').each(function() {
$(this).closest('.mod__, l').append(({
 m1: mod__c1,
 m2: mod__c2,
 m3: mod__c3,
})[$(this).data('mod')]);
});
Ah Ah Ah, how short and beautiful!
Thank you! - Alysha_Becker61 commented on June 4th 19 at 16:49

Find more questions by tags jQuery