jquery
  • cookies
  • refresh
  • radio
  • 2014-02-17 60 views 0 likes 
    0

    我試圖將單選按鈕值傳遞給cookie並單擊刷新我的頁面。我的代碼:單擊單選按鈕後如何設置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(); 
    }); 
    

    但它不起作用,因爲頁面沒有刷新點擊後。我應該如何更改我的代碼才能正常工作?

    +0

    你應該認真升級你的jQuery版本 –

    回答

    0

    我覺得你可能會使用的版本greater than 1.8隊友,然後檢查其out.Try使用我們的代碼隊友的小提琴製作將可能使用的是舊的jQuery version.Try .. :)

    的jsfiddle

    http://jsfiddle.net/Q2gJD/

    +0

    謝謝,但我的jQuery版本是1.10.2。爲什麼它不起作用呢?任何想法? – user3182654

    +0

    它顯示任何控制檯錯誤.. ?? – Outlooker

    +0

    不,完全沒有錯誤,但我決定再次升級我的jQuery並且它可以工作。謝謝。 – user3182654

    相關問題