Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're including the <a href="http://jqueryui.com/demos/button/" rel="noreferrer"><code>.button()</code> plugin/widget</a> that jQuery UI contains (if you have the full library and are on 1.8+, you have it), you can use it to disable the button <em>and</em> update the state visually, like this:</p> <pre><code>$(".ui-dialog-buttonpane button:contains('Confirm')").button("disable"); </code></pre> <p><a href="http://jsfiddle.net/nick_craver/rxZPv/1/" rel="noreferrer">You can give it a try here</a>...or if you're on an older version or not using the button widget, you can disable it like this:</p> <pre><code>$(".ui-dialog-buttonpane button:contains('Confirm')").attr("disabled", true) .addClass("ui-state-disabled"); </code></pre> <hr> <p>If you want it inside a specific dialog, say by ID, then do this:</p> <pre><code>$("#dialogID").next(".ui-dialog-buttonpane button:contains('Confirm')") .attr("disabled", true); </code></pre> <p>In other cases where <a href="http://api.jquery.com/contains-selector/" rel="noreferrer"><code>:contains()</code></a> might give false positives then you can use <a href="http://api.jquery.com/filter/" rel="noreferrer"><code>.filter()</code></a> like this, but it's overkill here since you know your two buttons. <em>If</em> that is the case in other situations, it'd look like this:</p> <pre><code>$("#dialogID").next(".ui-dialog-buttonpane button").filter(function() { return $(this).text() == "Confirm"; }).attr("disabled", true); </code></pre> <p>This would prevent <code>:contains()</code> from matching a substring of something else.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload