Something like this would work I think:
var dbox = $('#<DIV ID>');
var cbox = $(':checkbox', dbox); // This should be the checkbox.
I don't know if you can do it like this or not as I've never tried:
var cbox = $(':checkbox', $('#<DIV ID>'));
In either case, I prefer the two lines as I think it's more readable.
James
dalvarado wrote:
>
> Hi,
>
> I'm sure there's a shorthand way to do this. I'm trying to get the
> checked state of a checkbox, the only one, within a particular DIV. I
> would prefer not to use the ID of the checkbox but some more generic way
> of referring to the only checkbox within the DIV, id=dToDo1. I am fine to
> use the ID of the DIV in the shorthand expression. Here's how the HTML
> looks:
>
> <div class="sidebarToDo" width="100%" id="dToDo1">
> <table cellpadding="0" cellspacing="0" border="0" width="100%">
> <tr>
> <td><input id="cbTd1" onClick="var textDecor = (this.checked ?
> 'line-through' : 'none'); $('#textId1').css('text-decoration',
> textDecor);" type="checkbox" id="tdcb1" ></td>
> <td id="textId1" class="sidebarText" style="text-decoration: none">Wake
> Up</td>
> <td align="right"> # images/edit.gif </td>
> <td align="right"> javascript:toggleDiv('dToDo1');
> images/deleteLink.gif
> </td>
> </tr>
> </table>
> </div>
>
> Thanks for your help, - Dave
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/easy-way-to-get-checkbox-state-from-within-a-DIV-tf3262967.html#a9069810
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/