jQuery和IE:检查隐藏的输入" checked" -attribute不起作用 [英] jQuery and IE: Checking for hidden inputs "checked"-attribute does not work

查看:133
本文介绍了jQuery和IE:检查隐藏的输入" checked" -attribute不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试检查输入[type = hidden]是否有checked =checked属性。
输入字段如下所示:

I've been trying to check if my input[type=hidden] has an checked="checked" attribute. That input field looks like this:

<input type="hidden" checked="checked" name="1_WILLINFOS">

在Firefox中,通过使用它可以正常工作:

In Firefox it works just fine by using:

jQuery(selector).find('input[name=1_WILLINFOS]').attr('checked') == "checked"

但IE10总是给我一个假的。

But IE10 always gives me a false.

到现在我试图使用以下:

By now I tried to use the following:

.attr("checked") == "checked"
.attr("checked") == true
.is(':checked')

所有这些都给了我一个假的。

With all of them giving me a false.

任何想法?
谢谢

Any ideas? Thanks

推荐答案

您不能将隐藏输入设为复选框,因此它不会有已选中属性。您可以使用 type =checkbox并使用 display:none 隐藏它,如果您需要它是一个复选框,或者你可以简单地使用 0 1 的隐藏输入来代替模拟它。

You can't have hidden input be a checkbox, so it won't have a checked property. You can use a type="checkbox" and hide it with display:none if you need it to be a checkbox, or you can simply use the hidden input with a 0 or a 1 instead to kind of simulate it.

这篇关于jQuery和IE:检查隐藏的输入&quot; checked&quot; -attribute不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆