Solved

jQuery enable checkbox

Posted on 2013-06-29
4
377 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 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn how to dynamically set the form action using jQuery.
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)

751 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