Bạn đang xem: How to disable or enable a form element using jquery
Xem thêm: Dc Là Gì - Nghĩa Của Từ Dc Trong Tiếng Việt
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 mặc định 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) lớn 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 mặc định 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) lớn 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.