I'm not able to get the data attribute from a button element.
<button
class="btn btn-solid navigate"
value="2"
data-productId={{$product->id}}
id="size-click"
>
Next
</button>
Then I attempt to get it like so:
$("#size-click").click(() => {
let width = $("#prod-width").val();
let height = $("#prod-height").val();
var prodId = $(this).data("productId");
console.log('this is prodId');
console.log(prodId);
const data = {
prodId: prodId,
step: 'Size',
width: width,
height: height,
}
postDataEstimate(data);
})
I'm also trying this:
var prodId = $(this).attr('data-productId');
Can you let me know what I'm missing?