0

我做了一个小小的网络测验

问题是单击后退按钮时,我想重新选择用户的最后一个选择,但它似乎不起作用,我不知道为什么。

这是我的go_back功能:

function go_back(){
  $("#back").bind("click",function(){
    qNum--;
    if(AnsW.length === 0){
      calcAnswers--;
    }
    tempAns = AnsW[qNum];
    //user's last answer, which is false. I need this to make the radio button point to that answer.
    showQuestion(qNum);
    $("#contain").find("input[value="+tempAns+"]").prop('checked', true);
    AnsW.splice(-1,1);
    //delete the false answer from the array. I need this to make sure that the answer is deleted and there won't be an overload of wrong answers
    if(qNum === 0){
      $("#back").css({"visibility":"hidden"})
    }
  });
}
4

1 回答 1

-1

使用单选按钮中选择的属性。

<input type="radio" selected value="1"/>

Incase jQuery 试试下面,

$("radio option[value='B']").attr("selected","selected");
于 2013-07-05T12:26:52.500 回答