开发者

jqTransformReset() for the jqtransform form (Reset Button)

开发者 https://www.devze.com 2023-01-30 07:29 出处:网络
Does anyone have a complete code example for the jqTransformReset() for the jqtransform form? My ultimate goal is to add a reset button to the form and reset all form fields (especially checkboxes whi

Does anyone have a complete code example for the jqTransformReset() for the jqtransform form? My ultimate goal is to add a reset button to the form and reset all form fields (especially checkboxes which I 开发者_如何转开发can't get to reset). Thanks in advance!


whenever I call document.form.reset() I also call

$(".jqTransformCheckbox").each(function(){ if($(this).hasClass('jqTransformChecked')) $(this).removeClass('jqTransformChecked');});

seems to work fine.


jqTransform wouldn't reset select boxes for me or check boxes, so I made this bit of code and it seems to work well. (I used nando's code for the checkboxs, thanks nando)

$('.jqTransformButton[type="reset"]').click(function(){
    $(".jqTransformCheckbox").each(function(){
        if($(this).hasClass('jqTransformChecked')) {
            $(this).removeClass('jqTransformChecked');
        }
    });
    $('.jqTransform select').each(function(){
        var firstOpt = $(this).find('option:first-child');
        var firstVal = firstOpt.val();
        firstOpt.attr("selected", "selected");
        $(this).siblings('div').find('span').text(firstVal);
        $(this).siblings('ul').find('a.selected').removeClass('selected');
        $(this).siblings('ul').find('li:first-child a').addClass('selected');
    })
})
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号