你可以做这样的事情..
<!DOCTYPE html>
<html>
<head>
<style>
table {
font: 11px/24px Verdana, Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 320px;
}
td {
border: 1px solid #CCC;
padding: 0 0.5em;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#myRandomizeBtn").bind("click",randomizeHandler);
function randomizeHandler(evt){
var root=document.getElementById('mydiv');
var tab=document.createElement('table');
tab.className="mytable";
var tbo=document.createElement('tbody');
var row, cell;
var n = 3;
var data;
for (i=0; i<n; i++)
{
row=document.createElement('tr');
for(var j=0;j<n;j++){
cell=document.createElement('td');
data =window.prompt("b["+(i+1)+","+(j+1)+"] = ?");
cell.appendChild(document.createTextNode(data));
row.appendChild(cell);
}
tbo.appendChild(row);
}
tab.appendChild(tbo);
root.appendChild(tab);
}
});
</script>
</head>
<body>
<div id='mydiv'></div>
<button id = "myRandomizeBtn">Randomize</button>
</body></html>
这是一个工作小提琴