当使用bootstrap Radio而没有预先选择选项时,即使没有选择,也会检查第一个选项的结果
When using bootstrap Radio without preselecting an option, the first option result checked even if nothing is
我正在尝试使用Bootstrap Radio使用以下标记和js
<div class="form-control type">
<div class="radio-header">Please select the type of gallery item you want to create</div>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_image_0" value="image" name="dgt_gallery_item[0][type]" />Image</label>
<label class="btn btn-primary">
<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_quote_0" value="quote" name="dgt_gallery_item[0][type]" />Quote</label>
<label class="btn btn-primary">
<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_text_0" value="text" name="dgt_gallery_item[0][type]" />Text</label>
<label class="btn btn-primary">
<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_video_0" value="video" name="dgt_gallery_item[0][type]" />Video</label>
</div>
</div>
$( '#gallery_items .admin-card' ).each( function( index, element ) {
var name = $( 'input:radio:first', this ).attr( 'name' );
var type = $(' input[name="' + name + '"]:checked',this ).val();
switch_visibility_of_gallery_fields_by_type( type, this );
} );
.admin-card
是一个包含许多表单输入的伙伴字段。如您所见,html中没有预选选项,但在jQuery中,在firefox中,第一个单选结果被选中。在bootstrap中也是如此,因为选择第一个选项不会触发"change"事件。这在chrome 64 Windows中是预期的。知道在firefox上用什么吗?我需要获得第一个选中的单选项的值,如果没有选中,则为undefined
Firefox保持表单控件状态(禁用和检查)跨页面加载。一个解决方法是使用autocomplete="off"。
尝试为输入字段添加autocomplete="off"
。
<input type="radio" div_class="form-inline" class="visibility_switcher" id="type_image_0" value="image" name="dgt_gallery_item[0][type]" autocomplete="off" />
相关文章:
- Woocommerce产品选项有条件
- 在php和mysql中选择选项.一旦选择了选项,就列出我的sql数据库数据
- AngularJS ng选项在选择一个选项后删除了默认的空白值
- 或者在表单上选择默认选项文本(选择1)
- 隐藏/显示下面的分区根据是否选择某个选项进行选择
- 单击选项卡时jquery选项卡选择不起作用
- 删除“;选择“;从下拉菜单的选项中选择
- Angularjs使用ng选项进行选择
- 显示基于上一个se的选择的选择选项;选择
- 在带有 bootbox 的自定义对话框中添加选项以选择表单控件.js在 ASP.NET MVC 中
- <选项>在<选择>中的互斥
- 使用数组中的选项填充选择菜单
- 用于确定 AJAX 调用的引导选项卡选择
- 如何知道在所有选项中选择了哪个单选按钮
- 设置选择选项'选择'在模式引导中
- 动态添加选项以选择多个JQuery插件
- 禁用带角度ng选项的选择选项
- 菜单选项卡选择/活动样式取决于url中的file.php、javascript函数
- 鼠标传递选项时选择标记事件/使用onmouseover选择选项
- 当选择框选项有焦点时,Javascript事件不会触发