Jquery 单击单选按钮后如何设置cookie和刷新页面?

Jquery 单击单选按钮后如何设置cookie和刷新页面?,jquery,cookies,refresh,radio,Jquery,Cookies,Refresh,Radio,我正在尝试将单选按钮值传递给cookie,并在单击时刷新我的页面。我的代码: Inheritance Line: <label><input name='inheritanceline' type='radio' value="father" checked ></input>Father</label> <label> <input name='inheritanceline' type='radio' value="mothe

我正在尝试将单选按钮值传递给cookie,并在单击时刷新我的页面。我的代码:

Inheritance Line:
<label><input name='inheritanceline' type='radio' value="father" checked ></input>Father</label>
<label>
<input name='inheritanceline' type='radio' value="mother"></input>Mother</label>

$("input:radio[name=inheritanceline]").change(function () {
if ($(this).attr("checked") == "checked") {
    $.cookie('inheritanceline', $(this).val());
}
window.location.reload();
});
继承行:
父亲
母亲
$(“输入:radio[name=inheritanceline]”)。更改(函数(){
if($(this.attr(“已检查”)=“已检查”){
$.cookie('inheritanceline',$(this.val());
}
window.location.reload();
});

但它不起作用,因为单击后页面不会刷新。我应该如何更改代码以使其正常工作?

我认为您可能使用的是较旧的jQuery版本。请尝试使用大于1.8的版本
mate,然后检查它。尝试使用您的code mate制作的小提琴:)

JSFIDLE


您应该认真升级jQuery版本,但我的jQuery版本是1.10.2。那为什么不起作用呢?有什么想法吗?没有,根本没有错误,但我决定再升级一次jQuery,它就可以工作了。非常感谢。