jQuery(document).ready(function ($) {


    var max_fields = 10; //maximum input boxes allowed
    var wrapper = $(".input_fields_wrap"); //Fields wrapper
    var add_button = $(".add_field_button"); //Add button ID

    var x = 1; //initlal text box count
    $(add_button).click(function (e) { //on add input button click
        e.preventDefault();
        if (x < max_fields) { //max input box allowed
            x++; //text box increment
            $(wrapper).append(
                '<div>' +
                    '<a href="#" class="pull-right remove_field" data-chave="'+ x +'">X</a>' +
                    '<div class="form-group">' +
                        '<label class="control-label col-sm-2" for="email">Tipo:</label>' +
                    '<div class="col-sm-10">' +
                        '<select class="form-control" name="tipo[]">' +
                            '<option value="Whatsapp">Whatsapp</option>' +
                            '<option value="Telefone">Telefone</option>' +
                        '</select>' +
                    '</div>' +
                '</div>' +
                '<div class="form-group">' +
                    '<label class="control-label col-sm-2" for="pwd">Valor:</label>' +
                    '<div class="col-sm-10">' +
                        '<input class="form-control" type="text" name="valor[]" placeholder="Valor">' +
                    '</div>' +
                '</div>' +
                '<div class="form-group">' +
                    '<label class="control-label col-sm-2" for="pwd">Descrição:</label>' +
                    '<div class="col-sm-10">' +
                        '<input class="form-control" type="text" name="descricao[]" placeholder="Descrição">' +
                    '</div>' +
                '</div>' +
                '<hr/>' +


            '</div>'

            ); //add input box


        }
    });


    $(wrapper).on("click", ".remove_field", function (e) { //user click on remove text
        e.preventDefault();
        $(this).parent('div').remove();
        x--;
    })


});