Answers for "how to trim the file name when length more than 10 in angular"

0

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('.');
                    //file name
                    var fName = leftRightStrings[0];
                    //file extension
                    var fExtention = leftRightStrings[1];
                    var lengthFname = fName.length;
                    //if file name without extension contains more than 15 characters   
                    if(lengthFname > 15){
                        $(this).html(fName.substr(0,10) + "..." + fName.substr(-5) + "." +fExtention);
                    }    
        }); 
}); 
    <script>
Posted by: Guest on December-04-2020

Code answers related to "how to trim the file name when length more than 10 in angular"

Code answers related to "Javascript"

Browse Popular Code Answers by Language