Use .prev() if you are sure that they are next to each other. (This should be the fastest.)
var deleteid = $(this).prev().attr('value');
This gets the previous item.
If there is a possibility that there will be another element between them, you can use .siblings() :
var deleteid = $(this).siblings('.deleteid').attr('value');
This will lead all siblings to the same <div> with the deleteid class.
user113716
source share