(function(bts) {
bts.each(function() {
var inputs = $(this).closest('section').find('input');
inputs.on('change', verificarInputs.bind(this, inputs.get()));
});
function verificarInputs(inputs) {
var preenchidos = inputs.filter(i => !i.value).length == 0;
$(this).toggle(preenchidos);
}
})($('button''#addElements button'));
#addElements button {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="addElements">
<section>
<input type="text" name="exame" id="examedisciplina" placeholder="Nome da disciplina">
<input type="date" id="dataExame">
<button type="button" id="add_exame" onclick="addToTableExame()">Adicionar Exame</button>
</section>
<section>
<input type="text" name="teste" id="testedisciplina" placeholder="Nome da disciplinas">
<label id='label5'>Data:</label>
<input type="date" id="dataTeste">
<button type="button" id="add_teste" onclick="addToTableTeste()">Adicionar Teste</button>
</section>
<section>
<input type="text" name="trabalho" id="trabalhodisciplina" placeholder="Nome da disciplinas">
<label id='label6'>Data:</label>
<input type="date" id="dataTrabalho">
<button type="button" id="add_trabalho" onclick="addToTableTrabalho()">Adicionar Trabalho</button>
</section>
</div>
$(this).toggle(preenchidos);
Se quiseres manter o mesmo HTML podes fazer assim:
(function(bts) {
bts.each(function() {
var inputs = $(this).prevAll('input').slice(0, 2);
inputs.on('change', verificarInputs.bind(this, inputs.get()));
});
function verificarInputs(inputs) {
var preenchidos = inputs.filter(i => !i.value).length == 0;
$(this).toggle(preenchidos);
}
})($('#addElements button'));