wrap first n words with span
Hey,
I want to wrap a certain amount of
words in every h1 with a span.
The amount of words that I want to wrap are noted in the class of the headings (.hh-
n ).
So my html looks like:
- <h1 class="hh-1">wrap the first word</h1>
- <h1 class="hh-2">wrap the first two words</h1>
- <h1 class="hh-3">wrap the first three words</h1>
- <h1 class="hh-4">wrap the first four words</h1>
- $('h1').each(function() {
- hhNumber = $(this).attr('class').substring(4, 3);
- // ??
- });
please help!
best regards.