0
When using the script below it masks only the first line (if I filter or fetch it even changes what is first, but masks only the first from above). Someone can help me?
HTML:
@foreach($senhas as $key => $value)
<tr>
<td>
<form>
<div class="form-group">
<input id="password-field" type="password" class="form-control" name="password" value="{{ $value->senha }}">
<span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
</div>
</form>
</td>
</tr>
@endforeach
SCRIPT:
<script type="text/javascript">
$(".toggle-password").click(function() {
$(this).toggleClass("fa-eye fa-eye-slash");
var input = $($(this).attr("toggle"));
if (input.attr("type") == "password") {
input.attr("type", "text");
} else {
input.attr("type", "password");
}
});
</script>
HTML:<td> <form> <div class="form-group"> <input id="password-field" type="password" class="form-control" name="password" value="{{ $value->password }}"> <span toggle="#password-field" class="fa fa-Fw fa-eye field-icon toggle-password"></span> </div> </form> </td>
– Camila C. Piva
Are you sure your question is about PHP and foreach? It seems to be about JS. Please check if you posted the correct tags or if you posted the correct question.
– Woss
Where are you doing the foreach?
– Sam
I just updated the post.. thanks for the comments. Can help me?
– Camila C. Piva
Trade the line for
var input = $(this).prev();
... and do not repeat the<form>
inside the foreach.– Sam
@Sam worked perfectly!! Thanks <3
– Camila C. Piva
There’s a way I can get him to show off just for X seconds?
– Camila C. Piva
I changed the answer with the time you asked (2000 = 2 seconds).
– Sam
Perfect!! Thank you very much. ;)
– Camila C. Piva