0
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
});
<div id="flip"><table><td>Maria</td></table></div>
<div id="panel"><table><td>1.000</td></table></div>
<div id="flip"><table><td>José</td></table></div>
<div id="panel"><table><td>2.000</td></table></div>
Following the code above, I need to click on Mary and appear the value below (1,000), and the same with Joseph. It is working perfectly when you click on Maria, but not for José. How do I solve this problem?
You are using
id
which is a unique identifier and only the first element found in the document is selected, try switching to class, example<div class="flip"></div>
and$('.flip')
related https://answall.com/questions/39875/qual-a-prioridade-do-html-id-ou-class/39879#39879– abfurlan
The difference is that my original, it hides the line below and only when clicked, it appears, and its edition does the opposite.
– Rafael Brito
Look at the answer, if that’s what you want, see that I’ve added a
$(this).next('.panel')
to select the next element, i.e.– abfurlan