I cannot get a simple alert to fire when a checkbox is clicked/checked. I have been scratching my head wondering why I cant get it to work and I know it is going to be something simple... So, what am I doing wrong?
<script type="text/javascript">
$('#test1').click(function(){
alert('clicked');
});
</script>
<input type="checkbox" id="test1" value="test1" name="test1" value="-1">test1</input>
You are not waiting for DOM ready. If you will, it'll work:
<script type="text/javascript">
$(function(){
$('#test1').click(function(){
alert('clicked');
});
});
</script>
<input type="checkbox" id="test1" value="test1" name="test1" value="1" /> test1
Fiddle: http://jsfiddle.net/sanbc/