I’m trying to run a piece of code only when a checkbox is checked on refresh with the correct value?
if ($("input[name='business_group']").attr("checked")==true && .val("accommodation")) {
$(".acc_title").show();
$(".fd_title").hide();
$(".dest_title").hide();
$(".ttt_title").hide();
$(".c_name_container").show();
$(".stay").show();
$(".visit").hide();
alert("accommodation checked");
}
else if ($("input[name='business_group']").attr("checked")==true && .val("food_drink")) {
$(".fd_title").show();
$(".acc_title").hide();
$(".dest_title").hide();
$(".ttt_title").hide();
$(".c_name_container").show();
$(".stay").hide();
$(".visit").show();
alert("food_drink checked");
}
Any idea why the above code doesn’t work?
You jQuery code is slightly wrong, this should do what you want:
Infact it would be better to save this value into a variable: