Jquery method resolution to remove the last character of a string

  • 2020-03-30 01:41:17
  • OfStack

String: var s = "1,2,3,4,5,"

Target: delete the last ","

Methods:
S = s.s ubstring (0, s.L ength - 1);

Var s2 = "img/upload/123.jpg"

Target: get the file name (not including the suffix)

Methods:
S2 = s2. The substring (s2) lastIndexOf ('/') + 1, s2. The lastIndexOf ('. '));  


Related articles: