0
我是JavaScript新手,遇到問題。我希望實際的(函數updateBoxes)框[boxIx]比其他的更大,但我似乎無法找到可用的代碼。我試過盒子[boxIx] .size =「100px」; box [boxIx] .style.size =「100px」;沒有結果。這是我的代碼;如何獲得比其他人更大的實際箱子?
function init() {
box = document.getElementById("boxes").getElementsByTagName("div");
for (var i=0; i<box.length; i++) {
box[i].style.left = 70*i+"px";
} // End for
boxIx = box.length - 8;
updateBoxes();
} // End init
function browseLeft() {
if (boxIx > 0) boxIx = boxIx - 1;
updateBoxes();
}
// End browseLeft
function browseRight() {
if (boxIx < box.length-1) boxIx = boxIx + 1;
updateBoxes();}
// End browseRight
**function updateBoxes() {
box[boxIx].style.backgroundColor ="#CCC";
box[boxIx].style.top = "20px";
box[boxIx].style.zIndex = 9;**
var z = 8;
for (var i=boxIx-1; i>=0; i--) {
box[i].style.backgroundColor ="#666";
box[i].style.top = "0px";
box[i].style.zIndex = z;
z = z - 1;
} // End for
z = 8;
for (var i=boxIx+1; i<box.length; i++) {
box[i].style.backgroundColor = "#666";
box[i].style.top = "0px";
box[i].style.zIndex = z;
z = z - 1;
} // End for
} // End browseLeft
** function updateBoxes()'可能是一個格式錯誤,但是誰知道? – thirtydot 2011-06-15 14:48:19
所以你想更新寬度和高度?是否有任何理由不使用'box [boxIx] .style.width = box [boxIx] .style.height =「100px」;'? – 2011-06-15 14:52:19