-1

When I am check multiple check boxes form jQuery dialog box form attempt to update I used the below code:

 $(".chk").prop('checked', true); 

and the same code when i click UncheckAll not removed checked attribute i used the below code

$('.chk:checkbox').prop('checked', false);

then i changed to

$(".chk").val(0);
$(".chk").removeAttr("checked"); 
console.log(this); //Here remove all checked attribute

but when i submit the form that form not updated the same thing click CheckAll working fine but UncheckAll not working what is the problem

<input type="checkbox" class="chk" id="meters" name="Ids" value="0" ></input>

In my jps page multiple elements are there with name Ids i am expected array of Ids[0] in my form but the result is ids[2,3] like this I am using jquery 1.9.1 api

fbarikzehy
  • 4,885
  • 2
  • 33
  • 39

4 Answers4

1
 $('.chk:checked').removeAttr('checked');
Praveen
  • 55,303
  • 33
  • 133
  • 164
Alex Guerra
  • 320
  • 1
  • 6
0

Try this

 $('.chk').removeAttr('checked');
Jaimin
  • 7,964
  • 2
  • 25
  • 32
0
$('.chk:checkbox').prop('checked', false);
DevlshOne
  • 8,357
  • 1
  • 29
  • 37
0

You code works fine. The problem must be some where else in your code.

I've created a sample fiddle for example.

HTML:

<input class="chk" checked type="checkbox" />
<input class="chk" checked type="checkbox" />
<input type="button" value="Click Me" />

jQuery:

$('input[type=button]').on('click', function () {
    $(".chk").prop('checked', false);
});

Hope you're trying something similar to this.

Praveen
  • 55,303
  • 33
  • 133
  • 164