jeudi 5 mai 2016

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. demo: http://ift.tt/1q2ENX0

HTML:

<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>

Javascript:

$("input[name=a]").on("change",function(){
$("#demo").text("success!")})

Aucun commentaire:

Enregistrer un commentaire