Solved

jQuery enable checkbox

Posted on 2013-06-29
4
373 Views
Last Modified: 2013-06-29
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
0
Comment
Question by:ACEAFTY
  • 2
  • 2
4 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39286874
$(this).closest("input[type=\"checkbox\"]").prop('disabled',false);
0
 
LVL 1

Author Comment

by:ACEAFTY
ID: 39287225
I tried that but didn't work.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39287231
Try it this way round
$(this).parent('tr').find('td.delivery input').prop('disabled',false);
0
 
LVL 1

Author Closing Comment

by:ACEAFTY
ID: 39287241
That did the trick, thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now