Skip to content
Advertisement

Within a markup-string, how to replace any e.g. class-name specified element with its own title-text?

I have a variable called $text.

I want to make it so that if there are any spans with the class “emote”, replace the entire span and its contents with the title attribute of the span. Also, it must be case sensitive.

If $text had this as a value:

JavaScript

It would become this:

JavaScript

How could I achieve this?

Advertisement

Answer

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement