我在这里有这段代码:
<script type="text/javascript">
var catURL = window.location.pathname;
var catTitle = catURL.split("/");
catTitleNew = catTitle[4].replace("-", " ");
alert(catTitleNew);
//this will alert will convert this-is-my-title to this is-my-title
</script>
而且我认为我的替换代码不起作用,它只是替换第一个"-"
我如何让它替换所有的"-"
?