javascript - IE attach event to checkbox? -


i have html list of checkboxes don't know how 'document.attachevent' find checkboxes on onclick?

i wasn't sure if set event model specific ie in document.attachevent create loop goes through every checkbox , handles each one? also, checkboxes of different names can't checkboxname.attachevent unless did each one.

my elements dynamics enough tried adding en event broadest ancestor, document use event target , type no avail.

much thanks.

some fixes code:

document.attachevent('onclick', function (e) {     var target = e.srcelement;     if (target.type === 'checkbox') {         if(target.checked){             button.disabled = false;         } else {             button.disabled = true;         }            }  }); 

the third argument not used in ie's event handling model. e.srcelement refers clicked element.

i'd suggest wrap checkbox(es) in div or other element, , attach event listener wrapper. when page gets larger, checking clicks on document time consuming operation. if you've 1 checkbox, it's better attach handler ofcourse.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -