Could someone please help me work out this bit of code, it's driving
me crazy!
I've read here and there that "this" changes value according to its
level of enclosure, it can refer for example to an object that
triggers an event but then if used in callback it can refer to the
jquery function itself...

Well here's my bit of code that I'm working on.
I have a number of table cells that have checkbox inputs in them; I
have given to the table cells a "mychkbox" class.
I have another checkbox in a table cell, which when clicked selects
all of the others. I have put this checkbox in the "allchecked"
variable to simplify the code.
I want the mousedown event of all the "mychkbox" table cells to
trigger some events when "allchecked" is NOT checked.

$("td.mychkbox").each(                      // select all the cells
with class "mychkbox"
  function(){
    $(this).bind(                                   // apply the
mousedown event to each one of these
      "mousedown",                             // (and here $(this) is
correctly referring to those cells
      function(){                                    // because the
mousedown event is triggering correctly
        if (allchecked.attr("checked")==false){// only if allchecked
is NOT checked, do such n such

// Now what I need to do here is get the "checked" state of the
checkbox which is a child of the table cell.
// If I do:
          var itsme = this;                   // this seems to get the
table cell, in fact:
          alert(itsme);                         // gives me [object
HtmlTableCellElement]
// I can't seem to access any of the attributes of the table cell let
alone the children.
          alert(itsme.name);                // gives "undefined"
// or:
          var itsyou = itsme.attr("name");
          alert(itsyou);                        // gives no results,
it actually stops everything from working
// or:
          var itsyou = eccomi.find("input:checkbox");
          alert(eccoti);                        // gives no results,
it actually stops everything from working

        }
      });
    });
Hmmm... I'm stumped, I can't access the child checkbox, much less the
child checkboxes "checked" value.

Anyone have any ideas?

Reply via email to