I am building an app in ruby-sinatra that allows you to create posts and then reply to the post. I am trying to make the form for replying to a post appear when the user clicks Reply. However currently my code is only working for the first message div being rendered. All the others have the button to make the form appear but they dont work.
here is my .erb
<div class="message-link more ">
<div class="comment-square">
<% message.comments.each do |comment| %>
<% comment.users.each do |user| %>
<div><h5><%= user.username %></h5></div>
<% end %>
<script type="text/javascript">
$("#button").click(function() {
$("#fn").show();
$("#ln").show();
});
</script>
<p class="comment-text"><%= comment.text %>
<input id="button" type="button" value="Reply"><br>
</p>
<div id="fn" hidden><input type="text" /></div><br>
<% end %>
</div>
</div>
can anyone spot why?