Guest User

Untitled

a guest
Apr 25th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. $("#lastWord").html(function(){ // Class or id can be use
  2. var text = $("#lastWord").text().split(" "); // All text convert to array.
  3. var last = text.pop(); // Select last wrod.
  4. var first = text.shift(); // Select first word.
  5.  
  6. var firstW = first.innerHTML = '<span class="firstWord">' + first + '</span>'; // Make wrapper of first wrod
  7. var lastW = last.innerHTML = '<span class="lastWord">' + last + '</span>'; // Make wrapper of last wrod.
  8.  
  9. return firstW + " " + text.join(" ").concat( " " + lastW );
  10. });
Add Comment
Please, Sign In to add comment