我打算做的是讓每個單選按鈕組獨立工作。 請參考這http://codepen.io/anon/pen/tkqew如何讓一組單選按鈕(動態生成)獨立工作?
我想從每一行中選擇一個選項,但它只選擇一個選項。
在未來的工作中,我想動態地生成這個整個圖標線程,所以請如果你能建議我如何做到這一點。
我打算做的是讓每個單選按鈕組獨立工作。 請參考這http://codepen.io/anon/pen/tkqew如何讓一組單選按鈕(動態生成)獨立工作?
我想從每一行中選擇一個選項,但它只選擇一個選項。
在未來的工作中,我想動態地生成這個整個圖標線程,所以請如果你能建議我如何做到這一點。
通過爲組中的單選按鈕指定相同的name
屬性來創建單選按鈕組。簡單地給另一個共同的name
第二行的單選按鈕,以便他們將作爲一個不同的組...
但是將來可能會很長。因爲它會動態生成。所以這不會是理想的解決方案 –
那麼,你必須通過一些數據循環來創建這些......使用循環的索引來產生公共組......或者爲** future **場景提供一個小規模的例子,這樣我們可以拿出一些相關的東西.. –
@ user2043331你可以使用'index'就像:每次你創建一個組只需要'i ++'。 –
如果您使用循環來創建這些單選按鈕,使用索引(作爲前綴)單選按鈕名稱。
像:
<input type="radio" name="first_1">
<input type="radio" name="first_2">
1和2是這裏的指標..
您可以選擇單選按鈕多於一個選項,但不要把單選按鈕的名稱相同的其他按鈕,每個按鈕應該有獨特的名字。 這樣
<input type="radio" name="button1">
<input type="radio" name="button2">
還訪問您的link我已經改變了它
單選按鈕活動依賴於名字。如果你想要一組Radibuttons,只需命名該組。
<input type="radio" name="optionsRadios" class="optionsRadios2" value="option1" checked="checked" title="Nenhum">
{...}
<input type="radio" name="optionsRadios2" class="optionsRadios2" value="option1" checked="checked" title="Nenhum">
你需要給每個單選按鈕的「設置」不同的名稱:
<div class="icon-thread">
<ul>
<li>
<input type="radio" name="optionsRadios_set1" class="optionsRadios2" value="option1" checked="checked" title="Nenhum">
<label class="radio" for="optionsRadios2"><i class="icon-ban-circle icon-stack-base text-error"></i></label>
</li>
<li>
<input type="radio" name="optionsRadios_set1" class="optionsRadios2" value="option2">
<label class="radio" for="optionsRadios2"><i class="icon-fixed-width icon-moon"></i></label>
</li>
<li>
<input type="radio" name="optionsRadios_set1" class="optionsRadios2" value="option3">
<label class="radio" for="optionsRadios2"><i class="icon-fixed-width icon-plane"></i></label>
</li>
</ul>
</div>
<div class="icon-thread">
<ul>
<li>
<input type="radio" name="optionsRadios_set2" class="optionsRadios2" value="option1" checked="checked" title="Nenhum">
<label class="radio" for="optionsRadios2"><i class="icon-ban-circle icon-stack-base text-error"></i></label>
</li>
<li>
<input type="radio" name="optionsRadios_set2" class="optionsRadios2" value="option2">
<label class="radio" for="optionsRadios2"><i class="icon-fixed-width icon-moon"></i></label>
</li>
<li>
<input type="radio" name="optionsRadios_set2" class="optionsRadios2" value="option3">
<label class="radio" for="optionsRadios2"><i class="icon-fixed-width icon-plane"></i></label>
</li>
</ul>
</div>
編輯:順便說一句,你已經被濫用的標籤for
屬性。這應該匹配input
元素的id
。
http://codepen.io/anon/pen/CmzLf – Pranav