lundi 28 novembre 2016

how to remove the appended value if unchecked

here is my script i check the tr will append for view and i want to remove that when i click uncheck.

css 3 has to be removed because have unchecked it.

check and uncheck is happening from here

$("#jobSkills").on('change', '.selectPiSkill', function() {
    var count = $(this).attr('count');
    if (this.checked) {
        var title = $('#skill_' + count + '_title').val();
        var weightage = $('#skill_' + count + '_weightage').val();
        $('#PiSkills tr:last').after('<tr class="' + count + '"><td class="col-xs-4"><input value="' + title + '" readonly class="form-control text-center"></td><td class="col-xs-4"><input value="' + weightage + '" readonly class="form-control text-center" type="text"></td></tr>');
    } else {
        //unchecked remove tr
        $('#PiSkills tr.' + count).remove();
    }
});

<table id="PiSkills" class="table table-responsive" style="margin-bottom:5px">
    <tr>
        <th width="450"><input type="text" readonly value="Skill" class="form-control text-center">  </th>
        <th width="450"><input type="text" readonly value="Weightage(%)" class="form-control text-center"> </th>
    </tr>
</table>




Aucun commentaire:

Enregistrer un commentaire