Guest User

Untitled

a guest
Apr 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <span class="test1"> +123.23 </span>
  2. <span class="test2"> -13.23 </span>
  3.  
  4. <span class="test1"> 123.23 </span>
  5. <span class="test2"> 13.23 </span>
  6.  
  7. var val = $("span").html();
  8. $("span").html(val.substring(1, val.length);
  9.  
  10. $("span.test1, span.test2").each(function() {
  11. $(this).text($(this).text().replace(/[+-]/, ""));
  12. });
  13.  
  14. // get the current text
  15. text1 = $(".test1").html();
  16. // set the text to the substring starting at the third character
  17. $(".test1").html(text1.substring(2)); // extract to the end of the string
  18.  
  19. text2 = $(".test2").html();
  20. $(".test2").html(" " + text2.substring(2)); // looks like you want to keep the leading space
Add Comment
Please, Sign In to add comment