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

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

asked June 4th 19 at 16:44

1 answer

answered on

Solution

```
$('.mod__input').each(function() {
$(this).closest('.mod__, l').append(({
m1: mod__c1,
m2: mod__c2,
m3: mod__c3,
})[$(this).data('mod')]);
});
```

Find more questions by tags jQuery

Thank you! - Alysha_Becker61 commented on June 4th 19 at 16:49