2013-05-07 56 views
0

我正在尋找一個解決方案每一個按鈕被點擊一次更改多個按鈕,在選中的狀態中編輯按鈕。這裏的DIVJavaScript的 - 同一div但多個跨度

<div id="season" align="center"> 
    <span class="yui-button yui-radio-button yui-button-checked yui-radio-button-checked" id="season"> 
      <span class="first-child"> 
       <button type="button" id="season-button">Spring</button> 
      </span> 
    </span> 
    <span class="yui-button yui-radio-button" id="season"> 
      <span class="first-child"> 
       <button type="button" id="season-button">Summer</button> 
      </span> 
    </span> 
    <span class="yui-button yui-radio-button" id="season"> 
      <span class="first-child"> 
       <button type="button" id="season-button">Fall</button> 
      </span> 
    </span> 
    <span class="yui-button yui-radio-button" id="season"> 
      <span class="first-child"> 
       <button type="button" id="season-button">Winter</button> 
      </span> 
    </span> 
</div> 

我可以通過做訪問按鈕:

var groupName = document.getElementById(id).getElementsByTagName("button") 

但如果我嘗試

for (i = 0; i < groupName.length; i++) { 
     groupName[i].set("checked", false); 
    } 

什麼也沒有發生

任何幫助,不勝感激!

謝謝!

+0

'檢查'按鈕?你想要什麼? – Sachin 2013-05-07 02:28:33

+0

我正在創建一組按鈕,它們像單選按鈕一樣工作,即當選擇了一個時,先前取消選擇 – txcotrader 2013-05-07 02:32:52

+0

也許使用單選按鈕然後:這就是他們的意圖。如果您需要按鈕「外觀」,您可以將單選按鈕的標籤設計爲類似於按鈕的按鈕,例如, 'input [type =「radio」] + label {/ * inactive styles * /} input [type =「radio」]:checked + label {/ * active styles * /}' – thefrontender 2013-05-07 02:39:41

回答