2017-09-17 49 views
0

我有以下複選框代碼片段,我現在選擇了2個複選框現在我選擇第3個複選框。是否有任何方式獲得最新(第3個值)值?目前,我得到3個值。獲取最新選擇的值

<div class="aRow"> 
<label>Attach Photo:</label> 
<div class="form-multiselect binded binded-hover-intent" style=""> 
Select Attachment(s)<i></i> 
<ul class="round-corners-bottom" style="top: 27px; display: none;"> 
    <li class="light-gray multi-header"><label><input type="checkbox" class="form-checkbox select-all-drop">All Options</label> 
    </li><li><label><input type="checkbox" class="form-checkbox" checked="checked">Option 1</label></li> 
    <li><label><input type="checkbox" class="form-checkbox" checked="checked">Option 2</label></li> 
    <li><label><input type="checkbox" class="form-checkbox">Option 3</label></li> 
</ul> 
</div> 
</div> 
+1

請重申您的問題。現在沒有任何意義。 – tompec

+0

這將幫助你肯定https://www.codeproject.com/Questions/539709/Howplustoplusgetplusthepluslastplusselectedplusche –

+0

你到目前爲止做了什麼? –

回答

0

將「onclick ='checkboxChanged(this)'」添加到每個複選框。然後添加名爲checkboxChanged(chkbox)的JavaScript函數。

在該函數中,chkbox將引用剛纔單擊的複選框,然後您可以查看它是否被選中並訪問該值。

您可能還想添加一個onkeyup事件來處理鍵盤驅動的輸入。