IE中单选按钮的jquery操作问题
jquery action for radio buttons issue with IE
使用这里给出的方法-http://www.techiegyan.com/2008/07/09/using-jquery-check-boxes-and-radio-buttons/
我想显示字段时,"其他"单选按钮被选中,并隐藏相同的字段。
该方法在非IE浏览器上正确工作,但在IE上工作(几乎)相反…看起来IE会在取消选择选项时触发"change"事件,而不是在选择选项时触发。
这里是html:
<div><label class="option" for="selection-1"><input type="radio" id="selection-1" name="submitted[selection]" value="10" checked="checked" class="form-radio"> 10</label></div>
<div><label class="option" for="selection-2"><input type="radio" id="selection-2" name="submitted[selection]" value="20" class="form-radio"> 20</label></div>
<div><label class="option" for="selection-3"><input type="radio" id="selection-3" name="submitted[selection]" value="50" class="form-radio"> 50</label></div>
<div><label class="option" for="selection-4"><input type="radio" id="selection-4" name="submitted[selection]" value="100" class="form-radio"> 100</label></div>
<div><label class="option" for="selection-5"><input type="radio" id="selection-5" name="submitted[selection]" value="0" class="form-radio">other</label></div>
<div id="other-selection-wrapper">
<label for="other-selection">other:</label>
<input type="text" maxlength="10" name="submitted[other_selection]" id="other-selection" size="10" value="" class="form-text">
</div>
和脚本代码:
<script type="text/javascript">
$(document).ready(function(){
$('#other-selection-wrapper').hide();
$("input[@name='submitted[selection]']").change(function(){
if ($("input[@name='submitted[selection]']:checked").val() == '0')
{ $('#other-selection-wrapper').show(); }
else
{ $('#other-selection-wrapper').hide(); }
});
});
</script>
从你得到你的例子的网站
但是我忘了说,互联网剥削者只能在您使用时这样做.click()代替。change()
为什么要将无线电组分配给html数组?Name ="selection" is fine…
您应该能够显示/隐藏其他文本框,如下所示:
<div>.....</div>
<div><label class="option" for="selection-5"><input type="radio" id="selection-5" name="selection" value="0" class="form-radio">other</label></div>
<div id="other-selection-wrapper">
<label for="other-selection">other:</label>
<input type="text" maxlength="10" name="submitted[other_selection]" id="other-selection" size="10" value="" class="form-text">
</div>
jquery: $('input[name="selection"]:radio').click(function(){
if($('input[name="selection"]:radio:checked').val() == 0){
$('#selection-wrapper').css({'display':'block'});
}else{
$('#selection-wrapper').css({'display':'none'});
}
});
(未测试)相关文章:
- 选中复选框的Jquery/Javascript问题使用输入框操作将行从一个表添加到另一个表
- 控制器操作的路由问题
- DOM 操作、向后兼容性和跨浏览器问题
- 带有两个提交按钮的提交表单,每个按钮执行不同的操作问题
- jquery性能问题,操作注册
- 表单操作过程中出现后退按钮问题
- 这个Javascript出了什么问题"Internet Explorer无法打开Internet站点-操作中止
- 关于ShephredJS教程步骤操作的问题
- JavaScript 对象操作问题
- IE 中的 Jquery 输入文件类型操作问题
- j查询日历操作问题
- 似乎更多问题(单击查看更多 5-10 次后操作速度变慢)
- Javascript 操作顺序问题
- JavaScript DOM:html 表操作问题
- 解决所有延迟问题后执行某些操作
- Javascript/jQuery 范围和上下文问题,当试图操作对象的“引用”时
- 更改引导程序btn-css和悬停操作问题
- DOM操作问题
- “猫头鹰轮播”和“颜色盒”幻灯片操作问题
- IE中单选按钮的jquery操作问题