How can I remove the last element from a div?
I have a list of descriptions, and after removing one of them, I would like to remove the last element from the div, rather than refresh the site. I don't really know javascript, so I would like to ask how my destroy.js.erb should look like? I can update the "descriptions" of the whole class using
$('.descriptions').load(location.href + " .descriptions");
but I'm wondering if there is a way to remove only the last item.
<div class="descriptions">
<%= render @descriptions %>
</div>
//_description.html.erb
<div class="description-field">
<%= @description.text %>
</div>
Thanks for any help
+3
source to share
3 answers