Checkbox not working properly for IE with jquery

Posted by wildanjel on Stack Overflow See other posts from Stack Overflow or by wildanjel
Published on 2009-12-04T16:16:23Z Indexed on 2010/04/29 14:57 UTC
Read the original article Hit count: 154

Filed under:
|
|
|

Hi, I am trying using several asp.net checkboxes on a page, disabling them accordingly.

<asp:CheckBox ID='chkMenuItem' runat='server' CssClass='HiddenText' Text='Test'      onclick='<%#String.Format("checkChild({0});", Eval("id")) %>' />

on javascript, I am using the following code

function checkChild(id) {
            for (i = 0; i < $("input[id*=hdnParentMenuItemID]").length; i++) {
                if ($('input[id*=hdnParentMenuItemID]')[i].value.split(':')[0] == id) {
                    var childID = $('input[id*=hdnParentMenuItemID]')[i].value.split(':')[1];
                    if ($("#" + childID).attr("disabled"))
                    //$("#" + childID).attr('disabled', '');
                        $("#" + childID).removeAttr("disabled");
                    else
                        $("#" + childID).attr('disabled', true);
                }
            }
        }

Now is the checkboxes are disabled once the page is loaded, the removeAttr section doesn't work. I tried to step through the debugger and the logic works perfectly fine. If the checkboxes aren't disabled on page load, the code works fine. I tried replacing disabled 'attributes' with 'checked' to see if the other attributes work fine and it works perfectly fine. I tried

 $("#" + childID).attr('disabled', '');

but it didnt work either.

Note: It works perfect on FF and Chrome but doesnt work in IE.

Thanks,

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about checkbox