cult file extension from string javascript code example
Example 1: javascript find file extension from string
var ext = fileName.split('.').pop();
Example 2: how to trim the file name when length more than 10 in angular
<script src="js/jquery.js"></script>
<script>
$(document).ready(function(){
$('.uploadFilesItemHeader').find('#fileName').each(function() {
var fileNames = this.innerText;
var leftRightStrings = fileNames.split('.');
var fName = leftRightStrings[0];
var fExtention = leftRightStrings[1];
var lengthFname = fName.length;
if(lengthFname > 15){
$(this).html(fName.substr(0,10) + "..." + fName.substr(-5) + "." +fExtention);
}
});
});
<script>