on appended div first div`s radio checked automatic unchecked

whenever i try to clone div that time first div checked radio automatic unchecked..

why this is happen? anything i do wrong..

user checked radio than click on add button that time first checked value gone..but it shouldn't unchecked..

here is code.

var count = 1;
var is = 0;
var isx = 1;
$(function () {
    $("body").on('click', '.btn-add', function (e) {
        count++;
        e.preventDefault();
        if (count > 5)
            return;
        var controlForm = $('.miuplod:first'),
        currentEntry = $(this).parents('.uploadgroup:first'),
        newEntry = $(currentEntry.clone()).appendTo(controlForm);
        newEntry.find('input').val('');
        newEntry.find('input:radio').attr('checked', false);
        newEntry.find('input:radio[name="chotype' + is + '"]').attr('name', 'chotype' + isx);
        newEntry.find('input:radio[name="align' + is + '"]').attr('name', 'align' + isx);
        is++;
        isx++;
        controlForm.find('.uploadgroup:not(:last) .btn-add')
        .remove()
        .removeClass('btn-success');
        //.html('<span class="glyphicon glyphicon-minus">-</span>');
    }).on('click', '.btn-remove', function (e) {
        $(this).parents('.uploadgroup:first').remove();
        e.preventDefault();
        count--;
        is--;
        isx--;
        return false;
    });
});

please help me.. here is a jsfiddle link.

Answers 1

Related Articles