Reputation: 85
I currently use lastest jquery in my bootstrap but my javascript code is not working and lastest jquery. It's only work in jquery 1.7.2 but bootstrap need jquery 1.9.1 at least. What wrong with my code? Which part I need to change ?
Here is my code
$(document).ready(function(){
$("input:radio[name='highlight']").on('change',function(){
if ($('#radio7').attr("checked")){
$("#additional-service").addClass('shadow');
} else {
$("#additional-service").removeClass('shadow');
}
});
$("input:radio[name='highlight']").on('change',function(){
if ($('#radio8').attr("checked")){
$("#additional-service1").addClass('shadow');
} else {
$("#additional-service1").removeClass('shadow');
}
});
$("input:radio[name='highlight']").on('change',function(){
if ($('#radio9').attr("checked")){
$("#additional-service2").addClass('shadow');
} else {
$("#additional-service2").removeClass('shadow');
}
});
});
//]]>
Upvotes: 0
Views: 114
Reputation: 1828
It looks like you're trying to check wether some radio inputs are checked.
You can't do that with .attr()
with recent jQuery versions, you should use .prop()
instead :
$(document).ready(function() {
$("input:radio[name='highlight']").on('change', function() {
if ($('#radio7').prop("checked")) {
$("#additional-service").addClass('shadow');
} else {
$("#additional-service").removeClass('shadow');
}
});
$("input:radio[name='highlight']").on('change', function() {
if ($('#radio8').prop("checked")) {
$("#additional-service1").addClass('shadow');
} else {
$("#additional-service1").removeClass('shadow');
}
});
$("input:radio[name='highlight']").on('change', function() {
if ($('#radio9').prop("checked")) {
$("#additional-service2").addClass('shadow');
} else {
$("#additional-service2").removeClass('shadow');
}
});
});
Upvotes: 1