简体   繁体   English

获取最新选择的值

[英]Get latest selected value

I have following checkbox code snippet where I have 2 checkbox selected now I select 3rd checkbox.Is there any way that latest (3rd value) value get? 我有以下复选框代码片段,其中我选择了2个复选框,现在我选择了第3个复选框。最新值(第3个值)有什么办法获得吗? Currently, I am getting 3 values. 目前,我得到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>

Add "onclick='checkboxChanged(this)'" to each of your checkboxes. 将“ onclick ='checkboxChanged(this)'”添加到每个复选框。 Then add a JavaScript function called checkboxChanged(chkbox). 然后添加一个名为checkboxChanged(chkbox)的JavaScript函数。

Inside that function, chkbox will refer to the checkbox that was just clicked, and you can then see if it is checked or not and access the value. 在该函数内部,chkbox将引用刚刚单击的复选框,然后您可以查看是否选中了该复选框并访问该值。

You might also want to add an onkeyup event to handle keyboard-driven input. 您可能还想添加一个onkeyup事件来处理键盘驱动的输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM