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

时间:2014-02-17 11:54:37

标签: 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="mother"></input>Mother</label>

$("input:radio[name=inheritanceline]").change(function () {
if ($(this).attr("checked") == "checked") {
    $.cookie('inheritanceline', $(this).val());
}
window.location.reload();
});

但它不起作用,因为点击后页面没有刷新。我该如何更改代码才能正常工作?

1 个答案:

答案 0 :(得分:0)

我想你可能正在使用一个较旧的jQuery版本。尝试使用版本greater than 1.8配对,然后检查它。尝试使用你的代码伙伴制作的小提琴.. :)

的jsfiddle

http://jsfiddle.net/Q2gJD/

相关问题