Link to home
Start Free TrialLog in
Avatar of ACEAFTY
ACEAFTYFlag for United Kingdom of Great Britain and Northern Ireland

asked on

jQuery enable checkbox

Hi
I have a disabled checkbox in a table and want to enable it when the edit button is pressed. Not having much luck with this code.

        $(".edit").click(function(){
            if ($(this).hasClass("save")){
                console.log("save");
            }else{
                console.log("edit");
                $(this).closest("tr").find("td").each(function(){
                    if ($(this).index()!=0  && $(this).index()!=10){
                        if ($(this).hasClass("delivery")){

                            $(this).closest("input[type=\"checkbox\"]").prop({
                                disabled:false

                            });
                        }else{
                            $(this).html("<input type=\"text\" class=\"edit" + $(this).attr('class') + "\" name=\"" + $(this).attr('class') + "\" value=\""+$(this).text()+"\">")
                        }                                
                    } 
                }); 

Open in new window


I have a demo version live on: www.afthab.co.uk/test

Thanks in advance

Regards
Ash
Avatar of Gary
Gary
Flag of Ireland image

$(this).closest("input[type=\"checkbox\"]").prop('disabled',false);
Avatar of ACEAFTY

ASKER

I tried that but didn't work.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ACEAFTY

ASKER

That did the trick, thanks