0
I need to change the color of a button on a product list. However, I receive in a variable another list with the only logged-in user product id. Structure I receive :
[ 2, 7, 18, 21] // are the id of the logged in user products
Based on that, I wanted to know how I can change, using Jquery the color of the button of the list below, as the product id of the list below, equals the list of the structure above.
My list of products is:
<table id="produtos">
<thead>
<tr>
<th>Nome</th>
<th>Usuário</th>
<th>Quantidade</th>
</tr>
</thead
<tbody>
<c:forEach items="${produtos}" var="p">
<tr>
<td>${p.nome }</td>
<td>${p.usuario.nome }</td>
<td>${p.quantidade}</td>
<td>
<form id="testeForm" action="<c:url value="/atualizaQuantidade"/>" method="post" >
<input type="hidden" name="produto.cod" id="cod" value="${p.cod}" />
<button type="submit" class="btn btn-primary"></button>
</form>
</div>
</td>
</tr>
</c:forEach>
</tbody>
</table>
Matching the "Id", change the button color. My table then displays the product name, user name and quantity. I put a button to update, but I wanted it to have a different color if the user responsible for that product was logged in.
Example: user with id 7 logged in, only his products the button was in green color (example), not from it, permancesse the current button color.
Grateful
the content you posted is still too little to elaborate an ideal answer to your question, include your html and js.
– Leandro Angelo
Leandro, I put what you asked and added more information. Thank you for helping me.
– AmandaRJ