This is going to be straight forward for anyone who un开发者_如何学Cderstands this language.
I have a set of checkboxes, which I am successfully detecting via Javascript on window load.
I now need to detect any change in these checkboxes (ie checked/unchecked) and call in a function to do something else. However using this snippet causes the test function to fire on window load, not onclick, and I don't see why.
//action for county
if (parent != "innerpost") {
county[i].onclick test(name);
}//if
You need to write
county[i].onclick = function() { test(name); };
精彩评论