更新时间:2023-02-18 19:59:08
您只是用空字符串替换第一个非数字字符。请尝试使用:
You're replacing only the first non-digit character with empty string. Try using:
var id = window.location.href.replace(/\D+/g, '' ); alert(id);
(注意正则表达式末尾的全局标志)。
(Notice the "global" flag at the end of regex).