jQuery .prop(“disabled”, false) 在 Chrome 中不起作用
有问题 .prop("disabled", false) 它在 Opera 和 Firefox 中工作正常,但在 IE 和 chrome 中我无法让它工作..
实际上它是一种 invination 形式,我像这样制作发送按钮
<input id="sendInvite" class="mail_send" disabled="disabled" type="button" name="invite" value="Send">
,这里是 css
.mail_send[disabled="disabled"] {background-color:#343434; color:#747474}
所以正如您所看到的,按钮已被禁用,您无法单击,在该按钮被删除禁用后,您必须先写下您的姓名和邮件,然后才能发送邮件。 为此,我在这里编写的代码是: http://pastebin.com/8u23G90b
但这里出了点问题,在 chrome 和 IE 中禁用从未从按钮中删除,我还加载 jquery 1.7 .1
p.s 对不起我的英语
having problems with .prop("disabled", false) it's works fine in opera and firefox but IE and chrome i can't get it to work..
Actualy it's a invination form and im make send button like this
<input id="sendInvite" class="mail_send" disabled="disabled" type="button" name="invite" value="Send">
and here is css
.mail_send[disabled="disabled"] {background-color:#343434; color:#747474}
So as you can see button is disabled and you can't click, you must first write your name and mail after that button is remove disabled and you can send mail.
For this im write code here is:
http://pastebin.com/8u23G90b
But something is wrong here, in chrome and IE disabled never removed from button, im also load jquery 1.7.1
p.s sorry for my english
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
删除属性:
请参阅 .removeAttr() 了解更多详细信息
Remove the attribute:
See .removeAttr() for more details
你的问题不在于 JQuery,而在于你的 CSS 选择器。禁用属性指的是页面首次加载时的默认值,而不是元素是否实际上被禁用。
您想要的 CSS 选择器是 :disabled 选择器
:可以看到 this jsfiddle 的示例。
Your problem is not with JQuery, but with your CSS selectors. The disabled attribute is referring to the default value when the page first loads, rather than whether the element is actually disabled or not.
The CSS selector you want is the :disabled selector:
You can see an example with this jsfiddle.
尝试这样写:
Try to write it like that:
只需使用按钮即可直播:
just use button and live:
我遇到了类似的问题,我使用 .prop("disabled", false) 从“保存”按钮中删除禁用状态。禁用是通过 .prop("disabled", true) 分配的。
但是等一下,当尝试删除此属性(在 html 标记中将其呈现为禁用)时,我发现它被输出为 class="disabled"!
为此 - 我使用了 .removeClass('disabled')
我想说的是,如果事情没有按照您想象的方式进行,请确保它们的初始输出符合您的预期。
I was running into a similar issue where I was using .prop("disabled", false) to remove disabled from a 'Save' button. Disabled was being assigned via .prop("disabled", true).
But wait who what - when trying to remove this property (which would be rendered as disabled in the html tag) I discovered that it was being output as class="disabled"!
For this - i used .removeClass('disabled')
All i'm trying to say is if things don't work the way you think they should, make sure their initial output is what you'd expect.