2012-03-19 60 views
0

如何啓用單選按鈕點擊3張圖片的按鈕?滑門單選按鈕,如何啓用點擊/選中?

http://jsfiddle.net/eeda6/8/

<div class="newsRadioButtons"> 
<div class="radioAll"> 
    <div class="radioAllLeft"></div> 
    <div class="radioAllMiddle"> 
     <imput type="radio" checked="true" value="all" name="filter" />ALL 
    </div> 
    <div class="radioAllRight"></div> 
</div> 
<div class="radioImportant"> 
    <div class="radioImportantLeft"></div> 
    <div class="radioImportantMiddle"> 
     <imput type="radio" checked="true" value="all" name="filter" />Important 
    </div> 
    <div class="radioImportantRight"></div> 
</div> 

很抱歉的錯字錯誤

+3

你拼寫錯了。 'imput' =>'input'。 – 2012-03-19 09:54:41

回答

1

首先,你寫開關輸入,而不是輸入的通知。 至於解決方案,使用jQuery你可以附加一個事件到周圍的div,所以當點擊div時,他的輸入元素將被檢查。

$('.newsRadioButtons > div').on('click', function(e) { 
    $(this).find('input').prop('checked', true); 
}); 

添加代碼示例:http://jsfiddle.net/eeda6/14/

+0

嘿,快問題,你想要複製什麼確切的行爲? – 2012-03-19 10:16:01

+0

我看不到你已經把javacript放在那裏。這裏你去:http://jsfiddle.net/eeda6/14/ – iMoses 2012-03-19 10:16:52

0
<imput type="radio" checked="true" value="all" name="filter" /> 

<input type="radio" checked="true" value="all" name="filter" />