keep user checked radiobtn checked even after postback

后端 未结 2 2014
眼角桃花
眼角桃花 2021-01-26 09:44

I have the following radiocontrols with Default checked to \"All\". If user checks some other radio button and submits, on postback i want to retain the checked button, so user

2条回答
  •  萌比男神i
    2021-01-26 10:08

    Here's a quick way:

    var value = window.location.href.match(/[?&]type=([^&#]+)/) || [];
    
    if (value.length == 2) {
        $('input[name="EventType"][value="' + value[1] + '"]').prop('checked', true);
    }
    

    Here's a demo: http://jsfiddle.net/agW9g/

提交回复
热议问题