Dynamically change attribute of html button with Javascript

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

I have an html button where the ‘data-item-price’ attribute needs to be dynamically set on page load. The button has to be html but I can manipulate it with Javascript.

<button class=”snipcart-add-item”
data-item-id=”Job123″
data-item-price= 18 *a dynamically passed number*
data-item-url= “www.abc.co/priceevaluation”
data-item-name=”Validate”>
Add to cart
</button>

‫أضف إجابة

تصفح
تصفح

مجهول يجيب