Javascript .replace() not working

后端 未结 2 1188
[愿得一人]
[愿得一人] 2021-01-11 11:58
carList = cars.innerHTML;
alert(carList);
carList = carList.replace(\"
\",\"\").replace(\"
\",\"\").replace(\"\",\"\").replace(\"
2条回答
  •  不要未来只要你来
    2021-01-11 12:38

    You can use a regular expression to match all of these at the same time:

    carList = carList.replace(/<\/?(b|center)>/g,"");
    

    The g flag at the end of the match string tells Javascript to replace all occurrences, not just the first one.

提交回复
热议问题