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?
Kevin Martin
6,514
3
35
48
prodId
? - Majed Badawi - 8 hours agodata-productId={{$product->id}}
Your markup breaks after that - Kevin Martin - 8 hours agodata-productId="{{$product->id}}"
. @Kevin Martin - Arden Smith - 8 hours ago