Ah ha!
The .filter was it...
Just tweaked it to change the BG of the parent TD:
$(".checklist").filter(":checked").parent().css("background","lightgreen");
and it works. Thanks Wizz!
_______
SEAN O
Wizzud wrote:
>
> Try this ...
> $(".checklist").filter(":checked").css("background","lightgreen");
> If that still doesn't work, try putting $(this).css(...) inside an each()
> after the filter().
>
>
> Sean O wrote:
>>
>> 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#a8570486
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/