jQuery - 获取具有特定类的已选中复选框的值
16lz
2021-01-22
I'd like to get the value
of the checked checkbox that has the radioListMode
class:
我想获取具有radioListMode类的checked复选框的值:
<label class="btn btn-secondary active">
<input type="radio" class="radioListMode" value="cards" checked>Cards
</label>
<label class="btn btn-secondary">
<input type="radio" class="radioListMode" value="pins">Pins
</label>
From this previous question, this is what I have tried and it is undefined
:
从上一个问题来看,这是我尝试过的,它是未定义的:
console.log($('input[class="radioListMode"]:checked').value);
I do not wish to add a name
because the value of this checkbox is only used for layout selection, not any data input.
我不想添加名称,因为此复选框的值仅用于布局选择,而不是任何数据输入。
3 个解决方案
#1
3
Since you seem to be using jQuery, stick with it:
既然你似乎在使用jQuery,坚持下去:
$('input.radioListMode:checked').val();
更多相关文章
- 等待执行所有ajax回调的最佳解决方案
- 【问题解决方案】ImportError: No module named 'pygal'
- Python 黏包及黏包解决方案
- PyGobject(五十六)布局容器之TreeView(上)
- 无法安装ndg-httpsclient或者我的解决方案错误
- Linux无法连接网络解决方案
- Media-S 简介(一个开源的DRM解决方案)
- AppScan安全问题解决方案
- PLSQL乱码解决方案