Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery enable checkbox

Posted on 2013-06-29
4
Medium Priority
?
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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

670 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