IE11 zawiesza się podczas czyszczenia formularza zawierającego 5 lub więcej pól za pomocą JQuery $ (…) .val („”)

Jeśli usuwam formularz z 5 lub więcej polami w IE11 za pomocą $ ('form input'). Val ("") IE11 ulegnie awarii. HTML:

<form>
    <label>1</label><input type="text"/>
    <label>2</label><input type="text"/>
    <label>3</label><input type="text"/>
    <label>4</label><input type="text"/>
    <label>5</label><input type="text"/>
</form>

JS:

$(document).ready(function(){
    $('#clearFormNormal').click(function(){
        $("form input").val("");
    });
});

Kiedy robię to rekurencyjnie iz setTimeout działa.

JS:

function clearFields (counter) {
    var i = counter || 0, deferred = new $.Deferred();
    if ($("form input").eq(i).length === 1){
        setTimeout(function(){
            $("form input").eq(i).val("");
            i = i + 1;
            clearFields(i).always(function(){
                deferred.resolve();
            });
        },0);
    } else {
        deferred.resolve();
    }
    return deferred.promise();
}

$(document).ready(function(){
    $('#clearFormSetTimeout').click(function(){
        clearFields();
    });
});

Zobaczhttp://jsfiddle.net/fransoverbeek/Cy5D5/7/ także

Czy to błąd IE11?

questionAnswers(6)

yourAnswerToTheQuestion