JavaScript is not changing content of Bootstrap popover

Viewed 47

I am trying to create a popover that will show the bill according to the number of items.

I have created this popover with bootstrap

And I have created buttons to choose the number of the items and add them to the cart

document.getElementsByClassName("btnminus")[0].addEventListener('click', decrement);

document.getElementsByClassName("btnplus")[0].addEventListener('click', increment);

document.getElementsByClassName("adcart")[0].addEventListener('click', addcart);

function decrement() {
  var x = parseInt(document.getElementsByClassName("form-control")[0].value);
  if (x != 0) {
    document.getElementsByClassName("form-control")[0].value = parseInt(document.getElementsByClassName("form-control")[0].value) - 1;
  }


}

function increment() {
  document.getElementsByClassName("form-control")[0].value = parseInt(document.getElementsByClassName("form-control")[0].value) + 1;
}

function addcart() {
  document.getElementsByClassName("poper")[0].dataset.bsContent = "YOUR total bill is " + parseInt(document.getElementsByClassName("form-control")[0].value) * 125;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<a class=" " href="#">
  <button type="button" class="btn btn-lg poper" data-bs-toggle="popover" title="CART" data-bs-content="Your cart is empty"><img src="E:\Desktop\ecommerce-product-page-main\images\icon-cart.svg" alt="" width="" height="" class="d-inline-block align-text-top n"></button>

</a>
<div class="quantity d-inline-block">
  <input class="btn btnminus d-inline" type="button" value="-">
  <input class="form-control d-inline itemnumber" value='0' aria-label="Username" aria-describedby="addon-wrapping">
  <input class="btn btnplus d-inline" type="button" value="+">
</div>

<button type="button" class="btn btn-lg adcart">     <img src="E:\Desktop\ecommerce-product-page-main\images\icon-cart.svg" alt="" width="" height="" class="d-inline-block align-text-top n"> Add to cart</button>

</div>

But when add to cart button is clicked the popover data does not get changed. I am also getting this issue showing up while inspecting on chrome

Audit usage of navigator.userAgent, navigator.appVersion, and navigator. platform
0 Answers
Related