3 回答

TA貢獻1875條經驗 獲得超5個贊
<table border="0" cellspacing="0" cellpadding="1" class="formtable">
<tr>
<td>The following will contain masked input number </td>
<td id="output">XXXXXXX0230</td>
</tr>
<tr>
<td colspan="2"> If it is not masked number, then something is wrong.</td>
</tr>
</table>
文本和“輸出”數字之間的空格是由第二行中的較長文本引起的。這將導致第一行拉伸的第一列。你還在嵌套你不應該嵌套的元素。<tr>
您可以在第二行中添加 。colspan="2"<td>

TA貢獻1860條經驗 獲得超9個贊
上述答案都很好,除非第二個元素中的文本增加。我找到了一個更好的解決方案,它確實適用于我的情況。而不是把 的值放在另一個,我可以內聯,在上一個和那樣的空間不會在那里。操作方法如下<td>#output<td><td>
Code
var str1 = "78896541230";
str1 = str1.replace(/.(?=.{4})/g, 'x');
document.getElementById('output').innerHTML = str1;
<table border="0" cellspacing="0" cellpadding="1" class="formtable">
<caption>Just for fun</caption>
<tr>
<td>The following will contain masked input number <strong id="output"></strong></td>
</tr>
<tr>
<td> If it is not masked number, then something is wrong.</td>
</tr>
</table>
添加回答
舉報