2015-09-30 46 views
-1

我總共有三個單選按鈕用於小額定值。由於我不喜歡「普通」單選按鈕,因此我使用的是字體超棒的圖標。如何在用戶點擊其中一個標記時將其標記爲:如何將一個無線電按鈕標籤設置爲'checked'?

<input id="rate-bad" name="rate" type="radio" value="bad" tabindex="5"> 
<label class="choice" for="rate-bad"><i class="fa fa-frown-o fa-3x"></i>bad</label> 

輸入按鈕被設置爲不可見。

有沒有類似'choice :: checked'的東西可以使用?

+1

檢查了這一點 - http://codepen.io/ jamesbarnett/pen/yILjk/ –

+0

Thanks Luis PA - 這使我的一天:input [type = radio]:checked + label { \t color:#000; } – Dublay

回答

1

你可以用jquery進行檢查。

例如

<input id="rate-bad" name="rate" type="radio" value="bad" tabindex="5"> 
<label id="bad" class="choice" for="rate-bad"><i class="fa fa-frown-o fa-3x"></i>bad</label> 

的jQuery:

$("#bad").click(function() { 
    $("#rate-bad").prop('checked', true); 
}); 
0
<input type="radio" name="imgsel" value="" checked="checked" /> 

這將幫助你作出的單選按鈕選中

相關問題