ankur0101 Posted March 15, 2013 Share Posted March 15, 2013 Hi, I have html code like, <script> $("#premium_seat").click( function(){ if($('#premium_seat').attr('checked') == 'checked') { alert('Bingo'); } }); </script> <div class="control-group"> <label class="control-label" for="inputEmail"><b>Premium Seat</b></label> <div class="controls"> <input type="checkbox" name="premium_seat" id="premium_seat" /> </div> </div> What I want to do is when I tick on this checkbox, it will show me Bingo Dialogue box. This works here > http://jsfiddle.net/TyMNp/ But on my designing page, it is not working at all. I am using jquery v1.7.2 However other jquery functions such as $(document).ready(function() { document.getElementById("premium_pointer").innerHTML=""; //$("#premium_amount :input").attr("disabled", true); }); are working fine Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/ Share on other sites More sharing options...
yomanny Posted March 15, 2013 Share Posted March 15, 2013 Is the click event code inside of document.ready ? I know I had trouble with stuff like this when my event-binding code wasn't inside of document.ready. - W Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/#findComment-1418806 Share on other sites More sharing options...
ankur0101 Posted March 15, 2013 Author Share Posted March 15, 2013 No, click event is not inside document.ready Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/#findComment-1418807 Share on other sites More sharing options...
yomanny Posted March 15, 2013 Share Posted March 15, 2013 Then put it in there and see if it helps, sir. Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/#findComment-1418815 Share on other sites More sharing options...
yomanny Posted March 15, 2013 Share Posted March 15, 2013 Working code <script> $('document').ready(function() { $("#premium_seat").click( function(){ if($('#premium_seat').is(':checked')) { alert('Bingo'); } }); }); </script> Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/#findComment-1418817 Share on other sites More sharing options...
ankur0101 Posted March 15, 2013 Author Share Posted March 15, 2013 That worked. Thanks yomanny Link to comment https://forums.phpfreaks.com/topic/275692-checkbox-with-jquery-not-working-at-all/#findComment-1418859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.