开发者

Javascript checkbox state change

开发者 https://www.devze.com 2022-12-28 19:18 出处:网络
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.

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); };
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号