Search Results

Search found 2 results on 1 pages for 'mphammad ashour'.

Page 1/1 | 1 

  • Possible defect with jQuery ':checked' selector (finding checked checkbox when there are none)

    - by Mphammad Ashour
    Found a strange thing. The following code is supposed to set a default value for a UI element based on whether one of a group of checkboxes (all having attribute name="privacy") is checked (in say, a form postback). If there is no value in the HTML sent by the server (the form is not a postback), the default value should be firstMenuItemKey. Otherwise, it should be the one checked in the underlying HTML. However, while this works on the first call to the URL that includes the form, a refresh of the page will set the value of defaultPrivacyValue to one of the privacy checkboxes'. I've checked that the server isn't checking the checkbox before the script runs (it's not). I've also checked whether somewhere else in the script is checking the checkbox (it's not). var defaultPrivacyValue = firstMenuItemKey; $('input[name=privacy]:checked').each(function() { defaultPrivacyValue = $(this).next().find('.name').text(); }); selectMenuItem(defaultPrivacyValue); When I chaged the selector to 'input[name=privacy][checked=checked]' it worked as expected. Is this a defect in the jQuery implementation of DOM retrieval based on the ':checked' selector???? I'm using jQuery 1.4.2. Thanks for any help you can give.

    Read the article

1