Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jQuery enable checkbox

Posted on 2013-06-29
4
Medium Priority
?
385 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

972 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