1
I have the following code:
var clicado = null;
$('.clicado').click(function(){
clicado = $(this).val();
$('#mostrarId').html(clicado);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-hover table-striped">
<tr>
<td>1</td>
<td>Primeiro</td>
<td>
<button type="button" value="1" class="btn btn-primary clicado" data-toggle="modal" data-target="#mostrar">Mostrar</button>
</td>
</tr>
<tr>
<td>2</td>
<td>Segundo</td>
<td>
<button type="button" value="2" class="btn btn-primary clicado" data-toggle="modal" data-target="#mostrar">Mostrar</button>
</td>
</tr>
<tr>
<td>3</td>
<td>Terceiro</td>
<td>
<button type="button" value="3" class="btn btn-primary clicado" data-toggle="modal" data-target="#mostrar">Mostrar</button>
</td>
</tr>
</table>
<div class="modal fade" id="mostrar">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Mostrar</h4>
</div>
<div class="modal-body">
<p>Mostrar esse registro?</p>
<table>
<tr>
<td id="mostrarId"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="confirmar">Confirmar</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</div>
When I click on the button show opens the modal and shows the index number that was clicked, how do I show the name, IE, when I click on the Index Show button 1 I would like to show only the line 1 in the modal with the index and the name that would be "First"?
How do I get another column
td
on the same linetr
?– Laércio Lopes
@Laérciolopes goes by the Dice da
<td>
within the functioneq()
,nome = $(this).parents('tr').find('td').eq(INDICE AQUI).text();
, Remember that these start at 0– Miguel
I get it, thank you.
– Laércio Lopes