获取最新的选定值

时间:2017-09-17 03:35:42

标签: php jquery

我有以下复选框代码片段,其中我选中了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 个答案:

答案 0 :(得分:0)

在每个复选框中添加“onclick ='checkboxChanged(this)'”。然后添加一个名为checkboxChanged(chkbox)的JavaScript函数。

在该函数中,chkbox将引用刚刚单击的复选框,然后您可以查看是否已选中它并访问该值。

您可能还想添加一个onkeyup事件来处理键盘驱动的输入。