-2

My Jquery version is 1.3.2

I am using this below code to select all checkboxes -

  $('#alldw').change(function(){
      if($(this).prop('checked')){
          $('tbody tr td input[id="dwchk"]').each(function(){
              $(this).prop('checked', true);
          });
      }else{
          $('tbody tr td input[id="dwchk"]').each(function(){
              $(this).prop('checked', false);
          });
      }
  });

But I am getting below error

Uncaught TypeError: Object [object Object] has no method 'prop' action:181
(anonymous function) action:181
jQuery.event.handle jquery.js:2568
elemData.handle.eventHandle

Any solution?

Note - I dont want to upgrade jquery as there are many dependencies on it

D3Systems
  • 147
  • 1
  • 2
  • 8

4 Answers4

2

prop is 1.6+. 1.3 is ancient. Use attr if you do not want to upgrade or change to

this.checked=true;

Your code is very inefficient. Also ID needs to be unique

$('#alldw').click(function(){
  var chk = this.checked;
  $('tbody tr td input[name="dwchk"]').each(function(){
    this.checked=chk;
  });
});

You may want to check out the answers to this question

Upgrade jQuery 1.4.2 to 1.9.1

Community
  • 1
  • 1
mplungjan
  • 169,008
  • 28
  • 173
  • 236
1

.prop() is a added in jquery version 1.6+. you need to use jquery latest version.

Nishit Maheta
  • 6,021
  • 3
  • 17
  • 32
0

Please update your jquery link, it can also be useful for other functions. Use the below jquery link version for the working of prop. You only need to change the ID's just, rest everything is fine. And the Jquery will handle everything

Jquery link

Nad
  • 4,605
  • 11
  • 71
  • 160
0

I think the :checked Selector is supported on version 1.3:

if($(this).is(':checked'))

Use it if you don't want to upgrade to a recent version of jQuery because it's an old project and you will have to change a lot of things in it then.

Verhaeren
  • 1,661
  • 9
  • 10