jQuery find file extension (from string)

前端 未结 8 1143
半阙折子戏
半阙折子戏 2020-12-13 02:13

I was wondering if it was possible for jQuery to find a file extension based on a returned string?

A filename (string) will be passed to a function (openFile) and I

8条回答
  •  伪装坚强ぢ
    2020-12-13 02:41

    var fileName = 'file.txt';
    
    // Getting Extension
    
    var ext = fileName.split('.')[1];
    
    // OR
    
    var ext = fileName.split('.').pop();
    

提交回复
热议问题