jquery - How to reset selected radio buttons when closing slideToggle? -
i have simple slidetoggle setup opens div on page. of divs have self test in them. i'm having trouble figuring out how reset radio buttons when div closed. here jquery:
$("h2.titletrigger").click(function(e){ e.preventdefault(); //toggle open/close div $(this).toggleclass("active").next().slidetoggle("fast"); return false; }); //self test $('input:radio').bind('change',function(e){ e.preventdefault(); var parentid = $(this).parents('.selftest').attr('id'); $('#'+parentid+' .selftestwrong').addclass('answershown'); $('#'+parentid+' .selftestanswer').slidedown(300); });
see working here: http://jsfiddle.net/3xbgu/
what best way reset self test it's un-selected state when user closes slidetoggle?
you can this:
$("h2.titletrigger").click(function (e) { e.preventdefault(); //toggle open/close div $(this).toggleclass("active").next().slidetoggle("fast"); // re-set radio buttons $('input:radio').prop('checked', false); // re-set labels class $('.selftestwrong').removeclass('answershown'); return false; });