0

I have the following div:

document.querySelector('.ducp-component-cart-item.cart-item.YQ.sm').children[0].children[0].innerHTML

Which has a string value:

Airline Fuel Fee - non-refundable (YQ)

I am trying to remove the "- non-refundable" text with the following but it doesn't change it:

document.querySelector('.ducp-component-cart-item.cart-item.YQ.sm').children[0].children[0].innerHTML.replace('<div class="seats-together"><div class="cart-item-label">Airline Fuel Fee - non-refundable (YQ)</div></div>', '<div class="seats-together"><div class="cart-item-label">Airline Fuel Fee (YQ)</div></div>');

The console does show that the change has happened but when checking the element the change does not reflect.

Screen-shot

AlamGeer
  • 67
  • 6
  • 2
    "The replace() method returns a new string" (first sentence of [doc page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)) –  Sep 20 '21 at 07:24
  • 2
    Store `document.querySelector('.ducp-component-cart-item.cart-item.YQ.sm').children[0].children[0]` in a variable. Then do `variable.innerHTML = variable.innerHTML.replace(...)` – Ivar Sep 20 '21 at 07:25

0 Answers0