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();

更多相关文章

  1. 等待执行所有ajax回调的最佳解决方案
  2. 【问题解决方案】ImportError: No module named 'pygal'
  3. Python 黏包及黏包解决方案
  4. PyGobject(五十六)布局容器之TreeView(上)
  5. 无法安装ndg-httpsclient或者我的解决方案错误
  6. Linux无法连接网络解决方案
  7. Media-S 简介(一个开源的DRM解决方案)
  8. AppScan安全问题解决方案
  9. PLSQL乱码解决方案

随机推荐

  1. Android判断网络状态是否断开+Android完
  2. Android中的RxJava
  3. android selector android:state_enabled
  4. Android监听器
  5. Android(安卓)ANR异常及解决方法
  6. Android Studio 3.0 新特性
  7. android 静默安装、卸载实现
  8. android:gravity android:layout_gravity
  9. Android 要想美化就用Shape
  10. Android(安卓)kxml解析WBXML