我想分割一个字符串并使用JavaScipt函数替换 字符串中的一个字符。我的功能如下..在JavaScript函数中分割和替换
<script>
function test(table, col) {
var table = document.getElementById(table);
for (x = 1; x < table.rows.length; x++) {
var temp = table.rows[x].cells[col].innerHTML;
table.rows[x].cells[col].innerHTML = .replace('P', 'B');
}
}
</script>
所以它传递以下字符串http://ff00.00--p.yos.local:3042/htmltemps/newtest.html
和 我期待这样的结果:http://ff00.00--b.yos.local:3042/htmltemps/newtest.html
。但我得到这个: b/htmltemps/newtest.html
。任何帮助都会被处理。
它应该是'temp.replace('P','B')'。 –