What is the best way to cut the file name from 'href' attribute of an 'a' element using jQuery?

后端 未结 6 560
傲寒
傲寒 2021-01-16 19:32

For example I\'ve got the simple code:

6条回答
  •  [愿得一人]
    2021-01-16 20:13

    var fileNames = new Array();
    
    $('.list a').each(function(i, item){
        fileNames.push(this.href.substring(this.href.lastIndexOf('/') + 1))
    });
    

    This will give you an array of all the filenames, then:

    for(var x=0; x

提交回复
热议问题