javascript - reacting to radio buttons with jquery
问题描述
I'm searching for a possibility to react with jquery or js, when a radio button is selected. My html
<div class="row" id="options2">
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-6">
<input id="delivery" type="radio" name="option2" class="icheck">Lieferung</input>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-6">
<input id="takeaway" type="radio" name="option2" class="icheck">Abholung</input>
</div>
</div>
I tried this solution
$("input[name='option2']").change(function(){
console.log('test');
});
Are there other possibilities to achieve this?
解决方案
呃,我错过了模板提供的icheck,下面的代码它可以工作。 https://github.com/fronteed/icheck
$('#delivery').on('ifChecked', function(event){
alert(event.type + ' callback');
});
推荐阅读
- sql-server - 如何更新列sql中的所有行
- ignite - 如何在瘦客户端中订阅缓存事件
- ios - iOS - 在 iOS 中使用 PSPDFkit 框架版本 7 滚动到下一页时,滑动条隐藏
- android - Android Google Map:根据地图的米和缩放级别计算要绘制的半径
- jquery - 如何使用 JQuery AJAX 在 GET 请求中将数组作为查询字符串传递
- android - 检查点环境问题中的 Android 7 和 Captive Portal 连接身份验证
- angular - 如何在 Angular 2 中调用特定的同级方法
- php - 致命错误:循环通过 14 个元素长的单字符数组时允许的内存大小耗尽
- python - 如何在 BigQuery WebUI 中创建隐藏数据集,同时保持 datastudio 连接成为可能?
- python - 轴之间不相等的宽度导致非对角线