2017-07-06 27 views
0

我想使用引導切換,但我不知道如何檢查當用戶檢查它打開或關閉,以便發送它使用Ajax。如何檢查引導切換檢查或不在jQuery

我該怎麼做?

<div class="checkbox"> 
    <label data-label-id="<?= $data->id; ?>" id="message_status"> 
     <input id="check_toogle" type="checkbox" data-toggle="toggle"> 
    </label> 
    <div class="delete_message"> 
     &#10060; 
    </div> 
</div> 

http://www.bootstraptoggle.com/

+1

他們的文檔概述瞭如何處理事件:http://www.bootstraptoggle.com/#events –

+0

可能的重複https://stackoverflow.com/questions/13323671/twitter-bootstrap-how-to-see-the -state-of-a-toggle-button – Kevin

+0

謝謝羅伯特C,我查了文檔,但是沒注意到這個 –

回答

1

我猜

$('#bsfdsf').is(':checked') 

是很長的路要走。如果選中複選框,則返回true,否則返回false

+0

非常感謝,但它沒有用,我用$(function(){ $('#toggle-event')。change(function(){ if($(this).prop('checked')){ alert('dfdfdf'); } }) })as Robert C建議表示感謝 –