从jquery的多选复选框中获取选中值
fetch checked value from multiselect checkbox in jquery
我已经给出了html
<ul class="ui-multiselect-checkboxes ui-helper-reset" style="height: 175px;">
<li class=" ">
<label class="ui-corner-all" title="" for="ui-multiselect-opps-option-0">
<input type="checkbox" title="" value="All" name="opps" id="ui-multiselect-opps-option-0">
<i>All</i>
</label>
</li>
<li class=" ">
<label class="ui-corner-all" title="" for="ui-multiselect-opps-option-1">
<input type="checkbox" title="" value="1" name="opps" id="ui-multiselect-opps-option-1">
<i>John</i>
</label>
</li>
<li class=" ">
<label class="ui-corner-all" title="" for="ui-multiselect-opps-option-2">
<input type="checkbox" aria-selected="true" checked="checked" title="" value="3" name="opps" id="ui-multiselect-opps-option-2">
<i>Tim</i>
</label>
</li>
<li class=" ">
<label class="ui-corner-all" title="" for="ui-multiselect-opps-option-3">
<input type="checkbox" aria-selected="true" checked="checked" title="" value="2" name="opps" id="ui-multiselect-opps-option-3">
<i>Tom</i>
</label>
</li>
</ul>
和包含给定的jquery代码
$("input[id^='ui-multiselect-opps-option']").attr('checked').val();
,但它不是抓取检查值,请指导我如何通过jquery获取多选检查值。
在jquery中使用.map()
它用于将数组或对象中的所有项转换为新的项数组。
var res = $("input[id^='ui-multiselect-opps-option']:checked").map(function() {
return $(this).val();
}).get();
console.log(res);
小提琴
相关文章:
- 在for循环中未获取JQuery/JavaScript对象值
- 点击获取jQuery上的href属性
- 如何获取jQuery Confirm(jConfirm)值并使用该值检查条件
- 通过传递的参数位置获取jQuery中图像的宽度
- MVC Syncfusion Grid-HTML EJ Grid-获取Jquery中所选行的主键
- 如何获取 jQuery 以触发本机自定义事件处理程序
- 如何获取 jQuery 回调触发返回值
- 如何在wordpress插件中获取jquery中的img url和文件url
- 我想知道如何只激活表单提交,而不获取jquery中ajax url的值
- 如何获取jQuery集合中的第k个元素..作为JQUERY元素
- 从aspx.cs页面获取jquery post中的Null响应而不是json
- 如何获取 jquery 变量 childeren
- 如何从每个对象获取jQuery的“title”和“url”值
- 如何动态获取jquery noConflict()的引用
- 用于获取jQuery元素或值的方法
- 获取jquery数组对象的第n项
- 获取jquery确认在函数中返回的结果
- 获取JQuery UI自动完成元素的索引
- 获取jQuery UI排序后的ID数组
- 获取 jQuery DataTable 中的元素