写了个简单的的小函数。
===============================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table border="1">
<tbody>
<tr>
<td id="cell1">沈冥峰</td>
<td id="cell2">没我</td>
<td id="cell3">帅</td>
</tr>
</tbody>
</table>
<br /><br />
<hr />
<input type="button" id="btn1" value="在前面加2个空格" />
<input type="button" id="btn2" value="在后面加1个空格" />
<script type="text/javascript">
function addEmpty(oDomId,oCount,ofront){
var dom = document.getElementById(oDomId);
var count = oCount || 1;
var frontFlag = ofront || false;
var str = " ";
var addStr = "";
for(var i=0;i<count;i++){
addStr = addStr + str;
}
if(frontFlag){
dom.innerHTML = addStr + dom.innerHTML;
} else {
dom.innerHTML = dom.innerHTML + addStr;
}
}
var btn1 = document.getElementById("btn1");
var btn2 = document.getElementById("btn2");
btn1.onclick = function(){
addEmpty("cell1",2,true);
};
btn2.onclick = function(){
addEmpty("cell2");
};
</script>
</body>
</html>