lundi 13 novembre 2017

Uncheck checked checkbox on button click

I have already tried all the given methods to uncheck checkbox in jquery, please find my below code.

$('#btnDeleteEnterpriseID').click(function () {
       $('#chkbox').prop('checked', false);
       $('#chkbox').removeAttr('checked');
       $('#chkbox').checked = false;
       $('#chkbox').attr('checked', false);
       $('#chkbox input:checkbox').attr('checked', false);
       $('#chkbox input[type=checkbox]').removeAttr('checked');
    });

Have tried with all methods that I could get till now.

Below is the code for my checkbox and button.

@helper DisplayMultiLine(string str) 
{ foreach (string s in str.Split(new char[] { ',' }))
 { <input type="checkbox" id="chkbox" value="@s"class="edit-mode" />@s <br />} 
}

Here, @DisplayMultiline is helper class which I used in Web Grid column as shown below,

grid.Column(columnName: "EnterpriseID", 
format:@<text><span class="display-mode">
<label id="EnterpriseId" ></label>
</span>@DisplayMultiLine(@item.EnterpriseId)</text>),

And I want this checkbox to get unchecked on click event of delete button, code for it given below.

<button type="button" id="btnDeleteEnterpriseID" 
value="Delete" class="cancel-user edit-mode" onclick="DeleteEnterpriseID()">Delete</button>

I am not getting my mistake, kindly assist.




Aucun commentaire:

Enregistrer un commentaire