So I am getting a string of HTML Markup like:
const markup = "<p>thank you for contacting us. <span class=“ck-restricted-editing-exception”>Your</span> case was logged as <span class=“ck-restricted-editing-exception”>Case ID</span> and is assigned to <span class=“ck-restricted-editing-exception”>Technician Name</span>. We will attempt to resolve your issue within the next <span class=“ck-restricted-editing-exception”>Time</span> hours.</p>"
What I want to do is select all the <span>s (one by one), get their inner content, store it in an array of objects and assign an unique id or something similar to the span.
Like so
const spanValues = [
{ spanId: 1, spanContent: 'Your' },
...and so on
]
I am thinking of splitting the string by "<span" and "</span>" in order to get an array and then looping over that array, finding all the elements that start with "<span" and are "</span>" and perform operations on those strings.
Can't figure out how can I get and store the values from the <span>s though
However it already is sounding like a messy solution. Anything else anyone can suggest?