如果您包括jQuery UI包含的.button()
plugin/widget个(如果您有完整的库,并且在1.8+上,您就有了它),您可以使用它来禁用按钮and,以可视化方式更新状态,如下所示:
$(".ui-dialog-buttonpane button:contains('Confirm')").button("disable");
You can give it a try here...or if you're on an older version or not using the button widget, you can disable it like this:
$(".ui-dialog-buttonpane button:contains('Confirm')").attr("disabled", true)
.addClass("ui-state-disabled");
如果你想把它放在一个特定的对话框中,比如说按ID,那么就这样做:
$("#dialogID").next(".ui-dialog-buttonpane button:contains('Confirm')")
.attr("disabled", true);
在其他:contains()
可能给出假阳性的情况下,您可以像这样使用.filter()
,但是这里的用法有点过头,因为您知道您的两个按钮.在其他情况下是这样的,它看起来是这样的:
$("#dialogID").next(".ui-dialog-buttonpane button").filter(function() {
return $(this).text() == "Confirm";
}).attr("disabled", true);
This would prevent :contains()
from matching a substring of something else.