<div
data-global-messages="{"addCartSuccessMessage":"successfully added","creditRepresentativeMessage":"Please contact your Credit Representative","nonStockMessage":"Non-stock item","addWishlistSuccessMessage":"Wish List.","itemExistsCartMessage":"Please review error(s) below. ","itemExistsWishlistMessage":"Please review error(s) below. ","nonAvailableMessage":"substitute.","creditDepartmentMessage":"Please contact Sea. "}">
</div>
How to get the attributes from above?
I tried document.querySelector('data-global-messages').getAttribute('addCartSuccessMessage')
which returns null
2
Answers
All data attributes are stored in the element’s
dataset
property.To access it you can do: