When I click on a "trash" button I want to delete the message block. There are multiple message blocks but they all have unique data-values
. The id
of the targeted block I want to delete is stored in the data-value
of .send-message-button
.
I tried making a variable that I could pass onto the targeted .messageblock
element. I checked with an alert
to see if the variable gets the proper number, which it does. However when I alert
the whole thing, it gives [object object]
(without the .remove
, of course).
How can I do this?
var trashid = $(".send-message-button").attr("data-value");
$('.message-block').attr("data-value", trashid).remove();