I want to change tag name inside some text for example;
<div class="col-sm-12 col-md-6 col-lg-4 float-left">
<div class="service-one__single">
<span class="service-one__dot-1">BLA BLA 1</span>
<span class="service-one__dot-2">BLA BLA 2</span>
<span class="service-one__dot-3">BLA BLA 3</span>
</div>
</div>
I want to replace <span>
tags with <p>
dynamically. After change i want to see codes like below;
<div class="col-sm-12 col-md-6 col-lg-4 float-left">
<div class="service-one__single">
<p class="service-one__dot-1">BLA BLA 1</p>
<p class="service-one__dot-2">BLA BLA 2</p>
<p class="service-one__dot-3">BLA BLA 3</p>
</div>
</div>
2
Answers
I found the solution... Here is the solution;
I used a
PHP
tool calledDOMDocument
to analyze HTML. It locates all<span>
elements within a<div>
with a particular class.Then, it substitutes each one with a
<p>
element containing the same text.Lastly, it displays the modified HTML.
Output