I have a page with lots of inputs.
<form action="">
<div class="row">
<label for="texto">texto</label>
<input type="text" class="nome">
<span class="repositorio"><span class="efeito"></span></span>
</div>
<div class="row">
<label for="texto">password</label>
<input type="password" class="email">
<span class="repositorio"><span class="efeito"></span></span>
</div>
</form>
CSS is more or less like this ...
<style>
form{
width: 200px;
margin: 200px auto;
}
.row{
background-color: #999;
}
label{
width: 100%;
background-color: #099;
display: block;
}
input.nome,
input.email{
height: 26px;
width: 100%;
border:none;
}
.repositorio{
height: 2px;
width: 100%;
display: block;
position: relative;
}
.efeito{
height: 100%;
background-color: #f00;
position: absolute;
left: 50%;
right: 50%;
transition:.5s;
}
.efeito.efeitoStart{
left: 0; right: 0;
}
</style>
and jquery:
$( ".nome" ).focusin( function () {
$('.efeito').addClass("efeitoStart");
});
$( ".nome" ).focusout( function () {
$('.efeito').removeClass("efeitoStart");
});
Obviously this works, but applies the effect to all inputs, since the class that receives the effect is the same, either for any input.
I could apply an ID for each input, but since the system contains many elements, I believe it would not be legal to have a large JS file.
How can I apply the effect class only in the span of the clicked input?