C
C
cfmm2015-10-07 14:48:40
JavaScript
cfmm, 2015-10-07 14:48:40

How to wrap all the words of a page in a span tag?

How to enclose all space-separated words that are visible in the browser window in a span tag in an html page?

For example, it was:

<div>
Слово1 
<p>Слово2</p>
<button>Слово3 Слово4</button>
</div>


It became:

<div>
 <span>Слово1</span>
 <p><span>Слово2</span></p>
 <button><span>Слово3</span> <span>Слово4</span></button>
</div>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2015-10-07
@cfmm

Something like this: jsfiddle.net/tadfd8t1 but I need to finish it, it seems to me ...

C
Curly Brace, 2015-10-07
@stasuss

regex!

S
Sergey Melnikov, 2015-10-07
@mlnkv

you may ask why?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question