How to Remove last Comma?

后端 未结 12 1921
自闭症患者
自闭症患者 2020-12-08 06:58

This code generates a comma separated string to provide a list of ids to the query string of another page, but there is an extra comma at the end of the string. How can I re

12条回答
  •  再見小時候
    2020-12-08 07:45

    Here is a simple method:

        var str = '1,2,3,4,5,6,';
        strclean = str+'#';
        strclean = $.trim(strclean.replace(/,#/g, ''));
        strclean = $.trim(str.replace(/#/g, ''));
    
    

提交回复
热议问题