<title></title>
<style type="text/css">
img
{
width:200px;
height:100px;
}
</style>
<script type="text/javascript">
function add() {
var x = 1;
var table = document.createElement('table');
for (var i = 1; i <= 3; i++) {
var tr = document.createElement('tr');
for (var j = 1; j <= 5; j++) {
var td = document.createElement('td');
var img = document.createElement('img');
img.setAttribute('width', '200px');
img.setAttribute('height', '100px');
img.setAttribute('src', 'img/' + x + '.jpg');
x++;
td.appendChild(img);
tr.appendChild(td);
}
table.appendChild(tr);
}
document.body.appendChild(table);
}
function ReplaceNode() {
var imgNode = document.createElement('img');
imgNode.setAttribute('src', 'img/44.jpg');
var oldnode = document.getElementsByTagName('img')[8];
oldnode.parentNode.replaceChild(imgNode, oldnode);
}
function RemoveNode() {
var oldnode = document.getElementsByTagName('img')[11];
oldnode.parentNode.removeChild(oldnode);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="生成相册" οnclick="add()" />
<input id="Button2" type="button" value="修改相册" οnclick="ReplaceNode()" />
<input id="Button3" type="button" value="删除相册" οnclick="RemoveNode()" />
</body>