I have this code to add a class hidden
to a paragraph
But I have 3 input's and doing the same for each input
is a bit uncomfortable, I tried to do it with each
, but I was not successful.
The Inputs are the following:
$("#lastname").on('input', function() {
if((($(this).val().length)) > 0) {
$('#error-nombre').addClass('hidden');
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group">
<input type="text"class="form-control" id="lastname" name="lastname">
<p class="error-title hidden" id="error-lastname"></p>
</div>
<div class="form-group">
<input type="text"class="form-control" id="name" name="name">
<p class="error-title hidden" id="error-name"></p>
</div>
<div class="form-group">
<input type="text"class="form-control" id="age" name="age">
<p class="error-title hidden" id="error-age"></p>
</div>
I just want to have a function that detects me the input
I'm writing and add the class hidden