[jQuery] Yahoo Mail-like "Select All" check box (???)

[jQuery] Yahoo Mail-like "Select All" check box (???)


I'm on my first week of learning jquery and I'm totally hooked. I'm
converting/condensing a lot of my JavaScript to use jquery in my
project I'm working on. But now I have an issue, albeit, not an
urgent one. I read a blog post a while ago on some blog I can't
remember, where the person explained how to make a better "Select-All"
check box, like the one in Yahoo Mail. I figured out how to get the
select-all to work with the code below.
<script language="javascript" type="text/javascript">
$(function () {
$('#selectAll').bind('click', selectAll);
});
function selectAll(e) {
$(':checkbox').each(function() {
this.checked = e.target.checked;
});
}
</script>
When I click the "Select-All" check box, all the child check boxes are
checked. Now what I'd like is if one of the child check boxes are un-
checked then the "Select-All" check box is unchecked. Basically, the
same behavior you see in Yahoo Mail. If anyone has any idea on how to
accomplish this, or have a reference to an article describing how to
do this, I'd really appreciate if you'd pass it on.