Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#lastWord").html(function(){ // Class or id can be use
- var text = $("#lastWord").text().split(" "); // All text convert to array.
- var last = text.pop(); // Select last wrod.
- var first = text.shift(); // Select first word.
- var firstW = first.innerHTML = '<span class="firstWord">' + first + '</span>'; // Make wrapper of first wrod
- var lastW = last.innerHTML = '<span class="lastWord">' + last + '</span>'; // Make wrapper of last wrod.
- return firstW + " " + text.join(" ").concat( " " + lastW );
- });
Add Comment
Please, Sign In to add comment