Hi J.,

Thanks for the tips, but I can't seem to address every checkbox.

This code triggers the alert on load:
        if ( $(".checklist").is(":checked") ) {
                alert("found a checked box");
                $(this).parent().css("background","lightgreen");
        }

But the background is not changed.

Plus, the alert only fires once, so I take that to mean only one 'hit' was
found (in my test, 3 of the 8 boxes with checklist class were checked).
I need to have the CSS modify every checked checkbox with a class of
"checklist".


_______
SEAN O


j. siefer wrote:
> 
> ":checked" should work, in compination with is(":checked");
> 
> $(this).is(":checked").length ? alert("yes") : alert("no");
> 
> or something like this, try around
> or to highlight 
> 
> $(".checklist :checked").highlight();
> 
> 
> 
> 
> Sean O wrote:
>> 
>> Hi,
>> 
>> 
>> I have a "checklist" comprised of 8 checkboxes in a table, all with the
>> class "checklist".
>> 
>> I'm pulling the values from a database, and I want to highlight the
>> containing TDs green for the checkboxes that are checked, and leave the
>> rest alone.
>> 
>> I can do this onclick:
>>      $(".checklist").click(function(){
>>              ($(this)[0].checked) ?
>> ($(this).parent().css("background","lightgreen")) :
>> ($(this).parent().css("background","none"));
>>      });
>> 
>> Advice?
>> 
>> Thanks,
>> 
>> ________
>> SEAN O
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-tell-if-checkbox-is-checked-and-manipulate-tf3082108.html#a8569712
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to