I am trying to remove a DOM element by finding it in a property data-value. And I have a problem when this property contains the character '\'. Example:
<li class="tag" data-value="test\image">
<span>test\image</span>
<input type="text" value="test\image">
<i class="reset-clear-icon small"></i>
</li>
In my JS code, the element is deleted like this:
...
$tag.remove();
...
Is there any approach for a method to remove()work for backslash data? And in order for the data to be displayed correctly, without encoding a backslashcharacter in html, like this
$tag.replace("\\", "\")
so that it appears in html test\image.
source
share