0

I'm having a problem, getting & when set value of a input element by an element innerHTML this the element that i'm gonna take the innerHTML.

<div class="item">Printer & Scanner</div>

Then when i set the input value

inputElement.value = itemElement[x].innerHTML

The value became Printer &amp; scanner. I also try using the setAttribute('value', 'Printer & Scanner'); and still get the same result. It make the input looks ugly because &amp; showing in the input element. When i console.log(itemElement[x].innerHTML) the result is normal.

Is there any way that i can do to convert them? i already searching but found nothing.

Thanks

Irvan Hilmi
  • 336
  • 1
  • 2
  • 12
  • https://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it?lq=1 the best answer – Irvan Hilmi Dec 28 '21 at 02:32

0 Answers0