jQuery - uncheck input type "checkbox" programmatically inside each( )

in jQuery, how do I change this:

<input type="checkbox" checked="" style="width:100px;float:left;" value="1">

or this:

<input type="checkbox" checked style="width:100px;float:left;" value="1">

to this:

<input type="checkbox" style="width:100px;float:left;" value="1">


I want to programmatically uncheck all checkbox type inputs that are children of a div...


so far:

 function CheckAllRights(checkthem) {       

        $('#gridRightsList input').each(function () {
     
?????

        });
    }

Open in new window

LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
this should work:
$("input:checkbox","#gridRightsList").removeAttr('checked');

Open in new window

Sample:
http://jsfiddle.net/EE_RainerJ/x6b231s6/

HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
YTH   (yep, that helped)   : )

My final version:

function CheckAllRights(checkthem) {     
        if (checkthem == "no") {
            $('#gridRightsList input:checked').removeAttr('checked');
        }
        else {
            $('#gridRightsList input').attr('checked','checked');
        }
    }

Open in new window

0
Tom KnowltonWeb developerAuthor Commented:
Thank you!

Tom
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Tom KnowltonWeb developerAuthor Commented:
Actually, stop the train..

My "Select All" only works once.  After that it stops working.
0
Rainer JeschorCommented:
Hi,
wrong selector :-)

Please use
input:checkbox

Open in new window

instead of
input:checked

Open in new window


And that's for free :-)
0
Tom KnowltonWeb developerAuthor Commented:
And that's for free :-)


Nice!



Now it works consistently:

    function CheckAllRights(checkthem) {     
        if (checkthem == "no") {
            $('#gridRightsList input:checkbox').removeAttr('checked');
        }
        else {
            $('#gridRightsList input').prop('checked','checked');           
        }
    }

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.