Get product id with Jquery

2

I have the following code html :

  

When he clicks delete on div excluir-produto-carrinho he should get the id of the data-id-prod-cart . How do I do this?

I have tried the delete button which is the div excluir-produto-carrinho like this:

var idStorage = $(this).data('id-prod-carrinho'); 

and it does not work. Like it does not bring anything.

    
asked by anonymous 15.08.2017 / 16:06

1 answer

5

It's not working because it's not part of $ (this), you need to navigate:

var idStorage = $(this)
        .closest('.prodmostra')
        .find('.imagem-prod')
        .data('id-prod-carrinho');
    
15.08.2017 / 16:12