0
我是JavaScript新手,想弄清楚如何將一個Alt屬性添加到數組中。這是我到目前爲止。我將如何添加,並在哪裏?我想在身體/表上添加ALT =」「,但很明顯這不工作。在一個數組中添加一個alt屬性
<script type="text/javascript">
var pictures = new Array();
pictures[0] = new Image();
pictures[0].src = "image.jpg";
pictures[1] = new Image();
pictures[1].src = "image2.jpg";
<body>
var x = "<table>";
for (var y=0; y<rows; y++) {
x += "<tr> ";
for (var j=0; j<columns; j++) {
var ix = (y * rows + j) % pictures.length;
var id = y + "-" + j;
x += "<td> <img src=' " + pictures[ix].src +
"' " +
" id='" + id + "' " +
" height='300' width='300' ></td>";
嘿@ohdust,答案不適合你嗎?有什麼問題可以解決這個問題? – FRECIA