Showing posts with label checkbox in span jquery. Show all posts
Showing posts with label checkbox in span jquery. Show all posts

Wednesday, October 24, 2018

Find checkbox in span using jQuery

jQuery can be used to find and checkbox inside a span as shown below.


<span class="span1" >
        <input id="chkSelect" 
             checked="checked"
             type="checkbox" /></span>

<script type="text/javascript" >
        $(function () {
            $(".span1 input[type='checkbox']").click(function () {
                if ($(this).is(":checked")) {
                    alert("Checked");
                }
                else {
                    alert("UnChecked");
                }
            });
        });
   </script >