简体   繁体   中英

jquery selector missing children

My page needs to disable all of the elements in a large DIV but there is a button that will re-enable the same set of elements when clicked. My problem is that the first jquery works great and all elements are disabled. When my click event execute's the second jquery some but not all of the previously disabled elements are skipped over.

$('#FormLockingDiv').find('input, textarea, button, select, optgroup').attr('disabled', 'disabled');

$('#FormLockingDiv').find('input, textarea, button, select, optgroup').removeAttr('disabled');

I have tried the following selectors with the identical results:

$('#FormLockingDiv:disabled')
$('#FormLockingDiv[disabled]')
$('#FormLockingDiv').childeren

There are textareas buttons checkboxes and dropdownlists in the div and there does not seem to be a single tip the is consistently enabled.

EDIT: This is tied to using an ASP.Net Button in an ASP.Net UpdatePanel. On the post back of the panel I add a call to the unlock function but this seems have some interaction that causes the problem. This is throwing an error "Unterminated string constant". When I added standard buttons to trigger the same code that do not do a post back, all of the disabled elements are enabled. Could this have something to do with the form not being fully instantiated? Here is the command this triggered this error:

$('#FormLockingDiv').is(':disabled').attr('disabled', false);

Here are the functions

function Lockup() {
    $('#FormLockingDiv').find('input, textarea, button, select, optgroup').attr('disabled', 'disabled');
    $('.btnUnlockFormSelector').removeAttr('disabled');
}

function UnLockup() {
    $('#FormLockingDiv').is(':disabled').attr('disabled', false);
}

更改为:

$('#FormLockingDiv').find('input, textarea, button, select, optgroup').attr('disabled', false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM