here is my code. I am trying to get alert when checkbox checked and unchecked.
<html>
<script src="jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.checks').change(function(){
var qn=$(this).attr('id');
if($('#qn').prop('checked',true))
{
alert('question '+qn+' checked');
}
else
{
alert('question '+qn+' Unchecked');
}
});
});
</script>
</html>
<?php
for($i=1;$i<=5;$i++)
{
echo"<input type='checkbox' id='$i' class='checks' />Question-$i<br>";
}
?>
But when i check or uncheck only if condition is applying. Where i did the mistake