I want to run price_update() function on h6 element
{% for products in allProducts %}
<div class="col-6">
Final Price: <h6 id="final_price_{{product.slug}}" onload="price_update({{products.price}},{{products.offer}}, {{product.slug}})"></h6>
</div>
<script type="text/javascript">
function price_update(price, offer, slug) {
let discounted_price = price- parseInt(price * offer / 100);
let id = "final_price_" + String(slug);
let f_price = document.getElementById(id);
f_price.innerText = discounted_price;
}
</script>
{% endfor %}
I got to know that onload cannot be used with <h6> .
How can update innerText of <h6> for every product?