Learn free online HTML5, javascript, and jquery Tutorials by Examples

Sunday 1 June 2014

Check if Checkbox is checked using jQuery

--------------------------------------------
 <script src="http://http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
 <script>
    $(document).ready(function(e) {
        $('#btns').click(function(){
            var ischeck = $('#ss').prop('checked');
            alert(ischeck);
        });
    });
</script>





                                          -----OR----

<script>
    $(document).ready(function(e) {
        $('#btns').click(function(){
            $("input[type='checkbox']:checked").each(function() {
                       window.location.href = 'http://www.google.com';
                    });
        });
    });
</script>




<input type="checkbox" id="ss"  />
<button id="btns">check</button>


--------------------------------------------

No comments:

Post a Comment