HTML: 

```html
<input id="otherCheckbox2" type="checkbox" value="Accepted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" /> 
  <span style="color: Black">Accepted</span> <br />
<input id="otherCheckbox3" type="checkbox" value="Contracted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" />
  <span style="color: Black">Contracted</span> <br />
<input id="otherCheckbox4" type="checkbox" value="Pending" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" />
   <span style="color: Black">Pending</span><br />
<input id="otherCheckbox5" type="checkbox" value="Pre-Authorized" style="color: Black"  class="chkdisplay" onchange="javascript:othercheckbxdisplay();" />
   <span style="color: Black">Pre-Authorized</span> <br />
<input id="otherCheckbox6" type="checkbox" value="Show Deleted" style="color: Black" class="chkdisplay" onchange="javascript:othercheckbxdisplay();" />
   <span style="color: Black">Show Deleted</span> <br />
<input id="otherCheckbox7" type="checkbox" value="Treated" style="color: Black"　class="chkdisplay"　onchange="javascript:othercheckbxdisplay();" />
　　<span style="color: Black">Treated</span> <br />  

```

MY javascript function with jquery but it does not work.
called this function on a button click.Wen i click on button `alert("hi");` is fired but not `alert(index);` Also explain my main question and just me the way for this question

```js
 function ShowHideDxColumn() {
                alert("hi");
                $(".ckhdisplay").each(function (index) {
                    if ($(this).is(":checked")) {
                        alert(index);
                    }
                });
            }

```

thank u
['https://Stackoverflow.com/questions/17269744', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2194674/']
You have a typo, `.ckhdisplay` should be `.chkdisplay`. Because of that, your `.each` call has no elements to iterate over because there are none with the given class.

```
 function ShowHideDxColumn() {
     alert("hi");
     $(".chkdisplay").each(function (index) {
         if ($(this).is(":checked")) {
             alert(index);
         }
     });
 }

```

You actually don't really need the condiiton in the each, you can just select the checked checkboxes:

```
$(".chkdisplay:checked").each(function(index){
    console.log(this);
});

```
Please try this:

```
$.each($(".chkdisplay"), function(index, element) {
    if ($(this).attr('checked')){
        alert(index);
    }
});

```