jQuery find file extension (from string)

前端 未结 8 1138
半阙折子戏
半阙折子戏 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:51

    Since the extension will always be the string after a period in a complete/partial file name, just use the built in split function in js, and test the resultant extension for what you want it to do. If split returns only one piece / no pieces, it does not contain an extension.

提交回复
热议问题