我见过类似的问题,但似乎没有一个能满足我的需求。我需要根据列表禁用按钮。这是我的代码:
<button id="obj1" disabled>OBJ1</button>
<button id="obj2">OBJ2</button>
<button id="obj4" disabled>OBJ4</button>
<button id="obj5" disabled>OBJ5</button>
<button id="obj7">OBJ7</button>
<button id="obj8">OBJ8</button>
<script>
card_1_buttonList = new Array();
card_1_buttonList[0] = "1";
card_1_buttonList[1] = "2";
card_1_buttonList[2] = "4";
card_2_buttonList = new Array();
card_2_buttonList[0] = "5";
card_2_buttonList[1] = "7";
card_2_buttonList[2] = "8";
var CURRENTCARD = 2;
var BUTTONCOUNTER = 1;
var buttonDisabled = document.getElementById('obj' + card_CURRENTCARD_buttonList[BUTTONCOUNTER]).disabled;
alert(buttonDisabled);
</script>
如何在不修改现有数组的情况下做到这一点?