My script is failing in calling prop()
. I am getting the message:
JavaScript runtime error: Object doesn't support property or method 'prop'
$(document).ready(function() {
$("input:checkbox").click(function () {
if (!$(this).is(':checked')) {
$(this).prop('checked', true);
return;
}
var checkvalue = $(this).val();
$('input:hidden[id*="_PropositieType"]').val(checkvalue);
$("input:checkbox").not(this).removeAttr("checked");
});
});
I am using IE 11 and jquery 1.5.1. I want it to work with all browsers.
My script is failing in calling prop()
. I am getting the message:
JavaScript runtime error: Object doesn't support property or method 'prop'
$(document).ready(function() {
$("input:checkbox").click(function () {
if (!$(this).is(':checked')) {
$(this).prop('checked', true);
return;
}
var checkvalue = $(this).val();
$('input:hidden[id*="_PropositieType"]').val(checkvalue);
$("input:checkbox").not(this).removeAttr("checked");
});
});
I am using IE 11 and jquery 1.5.1. I want it to work with all browsers.
Share Improve this question edited Dec 2, 2015 at 10:32 Matteo Tassinari 18.6k8 gold badges63 silver badges84 bronze badges asked Dec 2, 2015 at 10:22 KimosKimos 992 silver badges10 bronze badges 8-
Don't use
click
, usechange
event – Tushar Commented Dec 2, 2015 at 10:23 - what jquery version you are using ? – Mayank Commented Dec 2, 2015 at 10:23
- isn't the default behaviour suppose to do what you are trying to do? – madalinivascu Commented Dec 2, 2015 at 10:25
-
1
I am not entirely sure, but I think
.prop
was not in jQuery as of version 1.5 – Niccolò Campolungo Commented Dec 2, 2015 at 10:32 -
1
jquery 1.5.1
that's said it all – A. Wolff Commented Dec 2, 2015 at 10:32
2 Answers
Reset to default 3Use j Query 1.6 or higher version
j Query 1.6+ uses
$('.Checkbox').prop('checked', true);
$('.Checkbox').prop('checked', false);
jQuery 1.5. and below
$('.Checkbox').attr('checked', true);
$('.Checkbox').attr('checked', false);
Try attr
in place of prop
. Because prop
is available in jQuery version 1.6+.
Here you can find the plete info.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744964532a4603593.html
评论列表(0条)