Frank Fan Frank Fan - 2 years ago 69
Javascript Question

if any of these checkbox with same name is changed, then do somthing

I would like to create several checkboxes. Then if any of the checkboxes's check status is changed, then do something like print out a word in a div.

The code in the demo doesn't work but it is the idea.


<input type="checkbox" name="a" value=1>Options1<br>
<input type="checkbox" name="a" value=2>Options2<br>
<input type="checkbox" name="a" value=3>Options3<br>
<input type="checkbox" name="a" value=4>Options4<br>
<input type="checkbox" name="a" value=5>Options5<br>
<p id="demo" style="background-color:yellow;">Not Succeed yet.</p>



Answer Source

You forgot to put jQuery in the fiddle:

Here is one where it works:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download