checkbox 选中的id拼接长字符串
生活随笔
收集整理的這篇文章主要介紹了
checkbox 选中的id拼接长字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
需求描述:為了做一個批量操作,需要獲取到checkbox選中的項的id,并且把選中的id拼接成字符串。
解決思路:先獲取到checkbox選中項,然后拼接。(這tm不廢話么),問題的關鍵就是獲取checkbox的選中項,廢話就不多說了直接上代碼
代碼:
//html<label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
<input type="checkbox" class="checkboxes" th:value="${xxx.xxxId}" value="id" name="id" /> <span></span>
</label>
//js
function enablBut(type,oper) { var selectIds;
$("input.checkboxes[name='id']:checkbox").each(function() {
if ($(this).is(":checked")) {
if (selectIds != "" && typeof (selectIds) != "undefined") {
selectIds += "," + $(this).val();
} else {
selectIds = $(this).val();
}
ableMany=true;
} });
if (selectIds == "" || typeof (selectIds) == "undefined") {
layer.msg("請選擇操作項!!");
return;
}
}
總結:每天記錄一點點,ヾ(?°?°?)ノ゙
轉載于:https://www.cnblogs.com/xuchao0506/p/9620548.html
總結
以上是生活随笔為你收集整理的checkbox 选中的id拼接长字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 今天来谈谈Python中的各种排序总结,
- 下一篇: Pycharm 2018.2.1-201