1
I have a table that shows values coming from the database. Below the line I am trying to run a div to use the toggle() function of jquery. I don’t know what I’m doing wrong, because when I click it shows everyone. I just want the clicked line to show the div. Personal thank you.
HTML:
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Nº do Cliente</th>
<th scope="col">Nome</th>
<th scope="col">Status</th>
<th scope="col">Corretor</th>
<th scope="col">Data de Cadastro</th>
<th scope="col">Ações</th>
</tr>
</thead>
<tbody>
<?php
//aqui fica uma função PHP de SELECT. tirei pra nao ficar grande o codigo html. =) {
?>
<tr style="padding:20px;">
<td>ID</td>
<td><span class="nomeTabela">Nome</span></td>
<td>Ativo</td>
<td>Eraldo Carlos</td>
<td>20/06/2018</td>
<tr class="tblOculto"><td>
<div class="divOculto">
Aqui vem a informação oculta.
</div>
</td></tr>
<?php
}
?>
</tr>
</tbody>
</table>
JQUERY:
$(document).ready(function(){
$(".nomeTabela").click(function(){
$('.tblOculto').css('display', 'block');
$(".divOculto").slideToggle("slow");
});
});
Cara happens that when you say "$(".nameTable")" all elements with this class will be affected. You have to perform the function only on the clicked element, and not on everyone who has the class. Search on the jQuery "$(this)" selector
– hugocsl
yes! I had searched with that selector. I did some bad tests I did not find. : / give a look here please if I am on the right track. thanks for answering! http://jsfiddle.net/j1khtc36/
– Joao Torres