The basic dialog window is an overlay positioned within the viewport and is protected from page content which is jQuery’s User Interface. To disable the button in a jQuery dialog from a function carried using jQuery based on the following approaches.
Approach 1:
- In UI Dialog box, button as default class called ui-button so focus on it.
- Create a function that should trigger dialog box in ready that is on page load.
- Then use jQuery method prop(‘disabled’, true) to disable that button with class ui-button.
Syntax:
$(selector).dialog(); $(selector).prop('disabled', true);
Example: Below example illustrates how to disable a button in a jQuery dialog from a function with help of prop() method.
|
Output:
Approach 2:
- In UI Dialog box, button as default class called ui-button so focus on it.
- Create a function that should trigger dialog box in ready that is on page load.
- Then use jQuery method attr(‘disabled’, true) to disable that button with class ui-button.
Syntax:
$(selector).dialog(); $(selector).attr('disabled', true);
Example: Below example illustrates how to disable a button in a jQuery dialog from a function with help of attr() method.
|
Output: