IE7中的jQuery启用/禁用提交按钮 [英] JQuery Enable / Disable Submit Button in IE7
问题描述
我正在使用以下代码禁用提交按钮
I am using the following code to disable the submit button
$("input[type='submit']").attr("disabled", "disabled");
此代码可以重新启用它:
And this code to re-enable it:
$("input[type='submit']").removeAttr("disabled");
除了Internet Explorer 7,它在我尝试过的所有浏览器上都可以正常工作.IE7将禁用该按钮,但是重新启用该按钮后,该按钮仍看起来被禁用.
It works fine on all browsers I've tried except Internet Explorer 7. IE7 will disable the button fine, but when it is re-enabled, the button still looks disabled.
尽管有光标和灰色,此按钮仍处于启用和可单击状态:
This button is enabled and clickable in spite of the cursor and gray color:
(一个同事在IE8上也遇到了同样的麻烦,但我无法重现它.)
(A colleague had the same trouble with IE8, but I could not reproduce it.)
我有一种解决方法可以完成这项工作,但是很丑陋.我有两个按钮,一个禁用,一个没有.首先,我将显示禁用的按钮并隐藏已启用的按钮.
I have a workaround in place that does the job, but its ugly. I have two buttons, one disabled, one not. To start, I show the disabled one and hide the enabled button.
$("input[type='submit']:first").css("display","inline"); //show disabled
$("input[type='submit']:last").css("display","none"); //hide enabled
...
<input name="Submit" type="submit" value=" Sign In " tabindex=3 disabled>
<input name="Submit" type="submit" value=" Sign In " tabindex=3 >
满足我的如果"条件后,我将隐藏已禁用的提交并显示已启用的提交.
When my "if" conditions are met, I hide the disabled submit and show the enabled one.
是否有更优雅的基于CSS或JQ的解决方案来解决此问题?
推荐答案
$("input[type='submit']").prop("disabled", false);
这篇关于IE7中的jQuery启用/禁用提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!